Questions tagged [stringtokenizer]

StringTokenizer is a Java class that breaks a string into tokens.

This tag is used for questions about or involving the StringTokenizer class in Java, which is used to break a single string into multiple, individual "tokens".

StringTokenizer is an old class, called the "legacy class" in documentation, suggesting to use String.split instead. However as of 1.7, it is not deprecated. Another class with similar but more advanced functionality is .

Questions tagged should also be tagged .

Useful links:

627 questions
3
votes
2 answers

Getting words using a StringTokenizer

I am currently trying to implement a Pokedex which just uses an array list to store Pokemon objects. this is supposed to be a command line interface with certain commands like add, remove, info, help, etc. I was just wondering the best way of…
user1874239
  • 305
  • 2
  • 6
  • 10
3
votes
4 answers

StringTokenizer not working properly with delim "//"

I am trying to break string on delim "//". My string also contains "/" and StringTokenizer giving strange result, it also break string on "/". String mStr = "abcd//aaa//32434//3/34343"; StringTokenizer tok = new StringTokenizer(mStr,…
Talha
  • 699
  • 2
  • 12
  • 33
3
votes
3 answers

Sending an array of values to Oracle procedure to use in WHERE IN clause

I have a stored procedure in Oracle as shown below: CREATE PROCEDURE MY_TEST_PROC( CUR OUT SYS_REFCURSOR, PARAM_THAT_WILL_BE _USED_INSIDE_WHERE_IN ) AS BEGIN OPEN CUR FOR SELECT * FROM MY_TABLE WHERE COL1 IN (here I want to…
Mikayil Abdullayev
  • 12,117
  • 26
  • 122
  • 206
3
votes
5 answers

Tokenizing a String with tab delimiter in Java while skipping some tokens

I have a huge file with data (~8Gb / ~80 Million records). Every record has 6-8 attributes which are split by a single tab. I would like for starters to copy some given attributes in another file. So I would like a more elegant code than the above,…
Michael
  • 791
  • 2
  • 12
  • 32
3
votes
3 answers

stringtokenizer returns wrong tokens

I want to "parse" a given string into vectors. A vector starts with "[" and ends with "]". The values of the vector as well as the vectors themself are seperated by ",". If I use integers as values my code works fine "[1,2,3],[5,2,3],[1,6,3]". But…
Drilon Berisha
  • 207
  • 1
  • 2
  • 14
3
votes
1 answer

Split text in JME and assign values in an array

I'm trying to create an array in j2me with split text. I'm trying to use the StringTokenizer class from ostermiller.org. However I can't figure out how to assign the tokens into an array. What could be wrong with this code? String[]…
sammyukavi
  • 1,501
  • 2
  • 23
  • 51
2
votes
5 answers

Break String into Sub-Strings, Android

I am making a program which would have the user enter a sentence and following that, the app would break the String into sub-strings where spaces are what break the original string up. import java.util.StringTokenizer; public class whitespace…
TomSelleck
  • 6,706
  • 22
  • 82
  • 151
2
votes
1 answer

tokenize string

I got a string with the following format : yyyyMMdd_HHmm_ss_unitCode_(status). I need to map each component to a property of a dedicated class. I thought of defining my token with a regular expression like this :…
charly's
  • 279
  • 1
  • 3
  • 16
2
votes
5 answers

splitting string into an array of ints

I have a string s="1,2,3,4,5" . I am using the split() method to split the string then i want to store it into an array of ints. I tried doing the following but it doesn't work. int i[]=Integer.parseInt(s.split(",")); I want to know if it is…
yahh
  • 1,175
  • 3
  • 14
  • 41
2
votes
3 answers

How to randomly access nth element in StringTokenizer

Is there anyway we can directly access a certain(lets say 20th) element in a stringTokenizer. Every now and then I need only a certain element from it and do not need others, yet I have to traverse through all elements. EDIT: I also want to ignore…
jem
  • 257
  • 4
  • 14
2
votes
2 answers

Java - Saving StringTokenizer into arrays for further processing in other methods

I've been coding Perl and Python a lot and this time I got an assignment to code in Java instead. So I'm not too familiar with handling data in Java. My task involves having a input file where I need to check dependencies and then output those with…
LynxLee
  • 321
  • 1
  • 6
  • 17
2
votes
3 answers

RegEx split string with on a delimeter(semi-colon ;) except those that appear inside a string

I have a Java String which is actually an SQL script. CREATE OR REPLACE PROCEDURE Proc AS b NUMBER:=3; c VARCHAR2(2000); begin c := 'BEGIN ' || ' :1 := :1 + :2; ' || 'END;'; end Proc; I want to split the script on…
Ali
  • 7,810
  • 12
  • 42
  • 65
2
votes
5 answers

char array variables are destroyed after exiting from function

I use strtok() to tokenize my string in a function. After copying the values to a global char array, I print the values to ensure the functionality. Everything is OK, but when I want to access them they are destroyed. this is the code: #include…
momo
  • 93
  • 1
  • 4
2
votes
2 answers

Spacy: how to add the colon character in the list of special case tokenization rules

I have the following sentence: '25) Figure 9:“lines are results of two-step adsorption model” -> What method/software was used for the curve fitting?' I would like to separate the colon from the rest of the words. By default, here is what Spacy…
Milos Cuculovic
  • 19,631
  • 51
  • 159
  • 265
2
votes
4 answers

Error whilst using StringTokenizer on text file with multiple lines

I'm trying to read a text file and split the words individually using string tokenizer utility in java. The text file looks like this; a 2000 4 b 3000 c 4000 d 5000 Now, what I'm trying to do is get each individual character from the text…
user734294
  • 23
  • 1
  • 1
  • 3