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
3 answers

Using StringTokenizer in Coverting words to number

Can anyone please help me on how to convert words into numbers in Java programming, using string tokenizer. Your answer will be highly appreciated. EDITED : I already made this code . but there is an error . like when i input one thousand one…
2
votes
1 answer

file reading using scanner and string tokenizer and retrieve adjacency list

import java.util.Scanner; import java.io.File; import java.io.FileNotFoundException; import java.util.StringTokenizer; public class Graph1 { public static void main(String[] args) throws FileNotFoundException { int linecount = 0, ec =…
Tintu James
  • 113
  • 1
  • 13
2
votes
2 answers

bufferedreader won't move to the next line

Good evening, I need to read some lines from a file, the file is csv and the file is structured like so: 4, Mo Farah,30, Jessica Ennis,27, i need to read those values and put them into variables, that's how i tried to do this: while(nextline !=…
user2209644
  • 701
  • 1
  • 9
  • 21
2
votes
2 answers

Java StringTokenizer considering parentheses

I am creating a program that tokenizes boolean logic expressions and returns the String array of tokens. The following is my code: public static String[] tokenize(String s) { String delims = "+"; StringTokenizer st = new StringTokenizer(s,…
2
votes
1 answer

Misbehaving JFlex rules - wrong rule matched

I'm writing a (simple?) JFlex tokenizer whose goal is to take a string, and tease apart the chunks that are in Chinese (or rather using the Han script), and the parts that are in a Latin script. The tokenizer is applied to brand names, and in my use…
RuslanD
  • 295
  • 3
  • 12
2
votes
2 answers

Count all characters in a file including \n etc

I am trying to iterate through a txt file and count all characters. This includes \n new line characters and anything else. I can only read through the file once. I am also recording letter frequency, amount of lines, amount of words, and etc. I…
user2541019
2
votes
5 answers

Simulating String.split using StringTokenizer

I'm converting code from an existing application to compile against a Java 1.1 compiler for a custom piece of hardware. This means that I can't use String.split(regex) to convert my existing string into an array. I created a method which should give…
JREN
  • 3,572
  • 3
  • 27
  • 45
2
votes
3 answers

Use StringTokenizer to count number of words and characters in words

The objective is to get a sentence input from the user, tokenize it, and then give information about the first three words only (word itself, length, and then average the first 3 word lengths). I'm not sure how to turn the tokens into strings. I…
Smeaux
  • 71
  • 1
  • 2
  • 6
2
votes
4 answers

String Tokenizing

I want to split a string with its tokens in java . for e.g; String s = "A#B^C&D!ased&acdf@Mhj%" String temp[] = s.split("[#^&!@%]+"); Current output :- temp[0] = A temp[1] = B temp[2] = C temp[3] = D temp[4] = ased output which i want :- temp[0] =…
Gaurav Singh
  • 12,707
  • 5
  • 22
  • 24
2
votes
4 answers

Remove spaces outside "" from String

How can I remove all whitespaces that are outside "" on a String? For example: 0507 ? "Y e a" : "No" Should return: 0507?"Y e a":"No" Thank you.
2
votes
2 answers

Java String separation

I am stuck trying to get the desired output. Its actually a string separation problem I am facing in the another problem. // Inputs String input1 = "=DIVIDE(Input!RC,Input!R[1]C)"; // B1 String input2 =…
user1655719
2
votes
2 answers

Java Split String Using Delimiter

Possible Duplicate: Matching a “.” in java I have a String 1.2.4 which i want to split and get 2 to compare it with another String that i get. I am trying to do the following StringTokenizer old_ver = new StringTokenizer(oldVersion, "."); …
Harsha M V
  • 54,075
  • 125
  • 354
  • 529
2
votes
2 answers

Scanner Class to create tokens of an input file

I have written the following code in java to open another .java file and create tokens (using scanner class) import java.io.FileReader; import java.util.Scanner; public class scanner1 { public static void main(String[] arg) throws Exception …
adeel iqbal
  • 494
  • 5
  • 23
2
votes
3 answers

StringTokenizer delimiters for each Character

I've got a string that I'm supposed to use StringTokenizer on for a course. I've got my plan on how to implement the project, but I cannot find any reference as to how I will make the delimiter each character. Basically, a String such as "Hippo…
user1588867
  • 67
  • 1
  • 3
  • 8
2
votes
3 answers

StringTokenizer for split space

I have strings follow format: 2012.11.15 22:00:00 1.2971 1.2974 1.2959 1.296 I use follow code: DateFormat df = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); String inputLine; in.readLine(); while…
Denis S.
  • 137
  • 2
  • 11