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

How to take StringTokenizer result to ArrayList in Java?

I want to take StringTokenizer result to ArrayList. I used following code and in 1st print statement, stok.nextToken() print the correct values. But, in second print statement for ArrayList give error as java.util.NoSuchElementException . How I…
Emalka
  • 381
  • 2
  • 4
  • 16
3
votes
2 answers

StringTokenizer Not Viewing Tab ("\t") as Whitespace ("\\s+")

Given a string in the form of: String myStr = "5.1\t3.5\t1.4\t0.2\t0.0"; If I call: StringTokenizer token = new StringTokenizer(myStr, "\\s+"); String firstElement = token.nextToken(); firstElement then equals the whole string. In contrast, if I…
ZaydH
  • 658
  • 6
  • 22
3
votes
1 answer

How to reuse a StringTokenizer Object

I have written some simple code where I am using a StringTokenizer to get input data one line at a time and then parseInt from it. InputStreamReader in = new InputStreamReader(System.in); BufferedReader r = new BufferedReader(in); int T =…
Ankit
  • 394
  • 1
  • 4
  • 16
3
votes
3 answers

StringTokenizer in JAVA

StringTokenizer is used to tokenize a tagged string in JAVA. The string is tagged using Parts Of Speech MaxentTagger of Stanford. Substring of the tagged text is taken to display just the POS tag and just the word iteratively. Here's the text before…
3
votes
2 answers

StringTokenizer vs split() in a program

I have to capitalize the first character of every word in a sentence. First character of the first word is in uppercase, and the sentence is to be terminated by a full stop or a question mark only. Then I have to count all the vowels and the…
Divyanshu Varma
  • 122
  • 3
  • 17
3
votes
2 answers

Java string.split( ) on comma or end-of-line

I'm terrible with regex stuff. I have data that looks like this: abc,42,4/04/1992,,,something, ,2/05/2007,dkwit,,334,,, The meaning of the data itself is somewhat irrelevant, the point is that it's comma-delimited, you could refer to the data…
rshaq
  • 149
  • 4
  • 13
3
votes
3 answers

check string with delimiter expected

I want to split string got from bluetooth. i'm using StringTokenizer splitStr = new StringTokenizer(readMessage, "\\|"); String numberSpeed = splitStr.nextToken(); //splitStr[0].replaceAll("\\D+",""); String numberTorque = splitStr.nextToken(); …
Martynas
  • 627
  • 2
  • 8
  • 28
3
votes
2 answers

How do I ignore parentheses while using string tokenizer to read in fractions?

public Fraction (String fractionString) { StringTokenizer st = new StringTokenizer(fractionString, "/"); numerator = Integer.parseInt(st.nextToken()); denominator = Integer.parseInt(st.nextToken()); } I have this so far. How do I change this…
3
votes
4 answers

StringTokenizer delimit once

I want to split a string (line) by the first whitespace, but only the first. StringTokenizer linesplit = new StringTokenizer(line," "); Take for example "This is a test". Then I want the strings to be "This" and "is a test". How could I use…
adrianp
  • 173
  • 1
  • 3
  • 17
3
votes
2 answers

Using string tokenizer to set create arrays out of a text file?

Hey. You may have recently seen a post by me looking for help, but I did it wrong before, so I am going to start fresh and begin at the basics. I am trying to read a text file that looks like this: FTFFFTTFFTFT 3054 FTFFFTTFFTFT 4674…
ashamadelion
  • 243
  • 1
  • 2
  • 9
3
votes
2 answers

How to get an required String using String Tokenizer

Im working with String Tokenizer API. Im not using Split() because Im working with jdk 1.3. I have an input String which is given below String input="Open_filedesc_count:mix:-1:-1:longterm:HML…
JAVA Beginner
  • 389
  • 3
  • 15
3
votes
2 answers

StringTokenizer - reading lines with integers

I have a question about optimization of my code (which works but is too slow...). I am reading an input in a form X1 Y1 X2 Y2 etc where Xi, Yi are integers. I am using bufferedReader for reading lines and then StringTokenizer for processing those…
Smajl
  • 7,555
  • 29
  • 108
  • 179
3
votes
2 answers

How do access specific tokens with Java's StringTokenizer?

I'm using Buffered Reader to pass individual lines of a file to Java's StringTokenizer. The file is structurd as follows:…
dwwilson66
  • 6,806
  • 27
  • 72
  • 117
3
votes
5 answers

What is difference between hasmoreelements and hasmoretokens in stringtokenizer java?

I am very much confused between hasmoreelements and hasmoretokens method of stringtokenizer. I want to know what's the difference Can anybody clear my confusion? Thanks
dev09
  • 159
  • 3
  • 11
3
votes
5 answers

Split string using pl/sql using connect level on null value

I'm using this following code in Oracle pl/sql (Version: Oracle Database 11g Release 11.2.0.1.0) select regexp_substr('A~B~C','[^~]+',1,level) output from dual connect by level <= length(regexp_replace('A~B~C','[^~]+')) + 1 which gives the…
Joshua
  • 173
  • 2
  • 3
  • 12