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
2
votes
4 answers

Using characters as a delimiter for StringTokenizer in Java

I am writing a program that takes an input of a list of numbers separated by commas and summing the total of the numbers. For example, I have the string "10, 20, 30, 40, 50" I want to extract each number, "10" "20" "30" "40" "50" separately from the…
Tommy Saechao
  • 1,099
  • 4
  • 17
  • 28
2
votes
3 answers

Java: Stringtokenizer To Array

Given a polynomial, I'm attempting to write code to create a polynomial that goes by the degree's, and adds like terms together For instance... given String term = "323x^3+2x+x-5x+5x^2" //Given What I'd like = "323x^3+5x^2-2x" //result So far I've…
Aaron
  • 49
  • 2
  • 8
2
votes
2 answers

Is StringTokenizer more efficient in splitting strings in JAVA?

I have been solving a problem Anti-Blot System from SPOJ First I tries splitting the input string using String's split method and i got TLE after submission My Code using split method import java.io.BufferedReader; import…
Aman Singh
  • 743
  • 1
  • 10
  • 20
2
votes
1 answer

Ant-contrib : equals doesn't work in for loop

I have a file build.properties: a=test1 b= c=test2 And a file build.xml :
user1517752
2
votes
3 answers

reading data from file and breaking it into tokens

I am using the following code after reading from a text file as to break the input of the text file into tokens: String input; while(true) { input = bin.readLine(); if (input == null) { System.out.println( "No data found in the…
user90790
  • 305
  • 1
  • 4
  • 13
2
votes
4 answers

Java String delete tokens contains numbers

I have a string like this and I would like to eliminate all the tokens that contain a number: String[] s="In the 1980s".split(" "); Is there a way to remove the tokens that contain numbers - in this case 1980s, but also, for example 784th or s787?
Enzo
  • 597
  • 1
  • 8
  • 22
2
votes
2 answers

Java Tokenization: Treat Anything Separated by an Underscore as One Word

I have a very simple tokenizer using StreamTokenizer, which will convert mathematical expressions into their individual components (below). The problem that I am having, is if there is a variable in the expression called T_1, it will split into…
Archetype90
  • 179
  • 1
  • 4
  • 19
2
votes
3 answers

How to make a Stingtokenizer for a char

I figured out how to do it for a String and an int but I am having trouble figuring it out for char. When I try to compile it gives me an error that I have a string token for a char. StringTokenizer stk = new StringTokenizer(line); String name =…
ttt
  • 39
  • 3
2
votes
1 answer

Returning the nth Token

I'm very new at Java and I have a question about a summer assignment. These are the instructions: Write a class called SpecialToken that has a static method called thirdToken. This method should return as a String, the third token of a String that…
user3930280
  • 21
  • 1
  • 2
2
votes
1 answer

Token replacement

I currently implement a replace function in the page render method which replaces commonly used strings - such as replace [cfe] with the root to the customer front end. This is because the value may be different based on the version of the site -…
ClarkeyBoy
  • 4,934
  • 12
  • 49
  • 64
2
votes
5 answers

StringTokenizer problem of tokenizing

String a ="the STRING TOKENIZER CLASS ALLOWS an APPLICATION to BREAK a STRING into TOKENS.  "; StringTokenizer st = new StringTokenizer(a); while (st.hasMoreTokens()){ System.out.println(st.nextToken()); Given above codes, the output is…
Mr CooL
  • 1,529
  • 8
  • 23
  • 27
2
votes
1 answer

trouble with StringTokenizer

I'm getting the following error message and I can't seem to figure out the problem. Would really appreciate any help. The error message reads as:- BaseStaInstance.java:68: cannot find symbol symbol : constructor…
leba-lev
  • 2,788
  • 10
  • 33
  • 43
2
votes
1 answer

StringTokenizer error

This is my first time using tokenizer for a fraction calculator of sorts. I tried following syntax as much as possible, but got this ugly, ugly error: Fraction.java:78: error: no suitable constructor found for…
brttwrd
  • 47
  • 1
  • 9
2
votes
3 answers

Tokenize strings in a batch file

Suppose I have a file, and I don't know how many words there are in it. I would like to go through this file and echo every word, one at a time. Is there a way to do that? The delim is space and I don't know how many words I will be going through…
user3420635
  • 21
  • 1
  • 2
2
votes
3 answers

java StringTokenizer unexpected results

i have the following code which will tokenize the string to create list of Objects: import java.util.StringTokenizer; public class TestStringTokenizer { private final static String INTERNAL_DELIMETER = "#,#"; private final static String…
A.Alqadomi
  • 1,529
  • 3
  • 25
  • 33