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
1 answer

Can I do StringTokenizer stk = new StringTokenizer(System.in)?

In Java, can I do StringTokenizer stk = new StringTokenizer(System.in); ? I am wondering if I can expect to collect the input stream as a sting like that or is there a better way of getting the user input converted to a string before I can use it…
Alain
  • 157
  • 1
  • 3
  • 14
-3
votes
2 answers

Problems with String Tokenizer

I have a set of 3 strings, each in different lines, which are integers separated by spaces. 1 1 2 3 4 4 4 5 5 I wanted to input them into a character array, and I used StringTokenizer in this manner: for(int j=0;i
user2277550
  • 553
  • 7
  • 22
-3
votes
2 answers

To ignore special characters and html code of a string and store the words in to one column of a table

I have a Code, import java.util.*; import java.util.Scanner; import java.util.StringTokenizer; class CountWords{ public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter string:…
user1334095
  • 87
  • 2
  • 4
  • 13
-4
votes
1 answer

Need help testing tokens against errors

I have to make a program that reads a text file and checks the 8 pieces of data on each line for certain criteria. I got the program to read the text file correctly, and I've implemented a tokenizer to split up the text file data into the 8 separate…
-4
votes
2 answers

How to solve 'NumberFormatException.forInputString()'?

My code is not working. The text file is in the same folder as my classes. I used the pathname, which worked, but I don't think that would work if I send the file to someone else. And converting the Strings to primitive type using parse methods…
-4
votes
5 answers

how to divide the string based on the # in android?

I have a string like "#123#456 #abc". my requirement is dividing the string into tokens based on the #. So my result tokens are #123,#456,#abc. How to divide the string in android?
Rajesh
  • 521
  • 5
  • 19
-4
votes
2 answers

Combining strings java (stringtokenizer)

I would like to combine a string of words for eg. aero-plane To do that , I would do a if else to check for the string "-" and if it is valid in the words it would then combine both aero and plane together to form aeroplane. I know how to do the…
-4
votes
2 answers

Split the words using string tokenizer if it is followed by two or more space/whitespace in java?

In my string, i want to tokenize string on the basis of two or more spaces. E.x. String str = "I am Chaitanya Gadam. Split this string." StringTokenizer tokenizer = new StringTokenizer(str); while (tokenizer.hasMoreTokens()) { String…
-4
votes
3 answers

string tokenizer in ios

I like to tokenize a string to characters and store the tokens in a string array. I am trying to use following code which is not working as I am using C notation to access the array. What needs to be changed in place of travel path[i]? NSArray…
pbd
  • 423
  • 3
  • 8
  • 19
-5
votes
1 answer

write a program that reads a sentance and write it on a file separating each word on a different line of the file (JAVA)

I need to do this exercise with java and I don't even know where to begin, someone told me I should use StringTokenizer and I have no idea how to use it or do anything else on the exercise. Can some of you help me? I'm watching tutorials on java but…
cherry
  • 39
  • 1
  • 1
  • 3
-6
votes
1 answer

JAVA: I have to write a program to read "sentences" from a file and and then count the number of words and vowels per sentence

I am working on a project where I wanted to create a file(ask user to input 'sentences'), read from it(read those sentences) and then find the number of words and vowels in EACH sentence. Then I had planned to display them is this manner: EXPECTED…
C0d3K1LL3R
  • 13
  • 1
  • 4
-8
votes
3 answers

How to store each word from a scanner to an array

I wan't to use the scanner to ask for input a few words and am expecting a delimiter ", " to separate each word. I then want to split each word and store it in an array so I could use it for other purposes i.e, instantiate an object with an array…
ferics
  • 77
  • 7
1 2 3
41
42