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

Assign Value to Empty Content in StringTokenizer

I have to read inputs from a file which consists of pipe delimetered strings A|UK|2|1 B||3|1 StringTokenizer st = new StringTokenizer(data,"|"); String id=st.nextToken(); String country=st.nextToken(); String count=st.nextToken(); String…
Bernad Ali
  • 1,699
  • 6
  • 23
  • 29
2
votes
4 answers

String Tokenizer changing Delimiters, don't show it

I need to split a string that is "Kermit D.Frogge", so this is the code I used: firstName = strTkn.nextToken(); middleInitial = strTkn.nextToken("."); //changing the delimiters to a . because there is no space between D and Frogge lastName =…
xSpartanCx
  • 281
  • 3
  • 10
  • 25
2
votes
2 answers

StringTokenizer doesn't show the 0 at the end of a number

i'm working with Java ,i'm using a StringTokenizer in order to have a part of my String but the problem is when i'm using "StringTokenizer" a part of my result doesn't appear this is my java code : for(String iopp:opp){ …
asmae
  • 31
  • 1
  • 1
  • 6
2
votes
1 answer

How to replace StringTokenzier(..., true) in GWT?

I am looking for a GWT compatible replacement for a StringTokenzier which includes the delimiter. The task cannot be solved by regular expressions because the grammar is not context free. Example: Extract the first level of a generic type…
2
votes
1 answer

Do tokenizers remove whitespaces?

Does Lucene's Standard Tokenizer remove whitespaces and blank lines? I've been reading the API (StandardTokenizer) but it's not specified. Maybe tokenizers do it by default, I don't know.
synack
  • 1,699
  • 3
  • 24
  • 50
2
votes
1 answer

Is there a function to cast string tokenizer to array

I am working over an hour to find a way to explode a string into a string array. This method have failed for me: lineFields = str.split("|"); System.out.print(lineFields.length); because it gives back an array of equal length to the string it…
Melsi
  • 1,462
  • 1
  • 15
  • 21
1
vote
3 answers

how can I use StringTokenizer with my jTable

I have a jTable and I want to display in it a result of a command,I used an object of the StringTokenizer class to separate the result pf the command cmd and display it in the table jTable1,my problem is when I use system.out.println(st.nextToken())…
hanem
  • 101
  • 1
  • 2
  • 7
1
vote
1 answer

Tokenizer in java dealing with spaces and apostorophes

I was wondering if there is any way in Java to tokenize an string by spaces, BUT if there are some words between apostrophes, take it as "one word"... so for example, if I have: This "is a great" day the string tokenizer should have: "This" "is a…
cafesanu
  • 435
  • 1
  • 4
  • 12
1
vote
3 answers

string tokenizer stopping after first line

I have a text file I am trying to break up with string tokenizer. Here is a few lines of the text file: Mary Smith 1 James Johnson 2 Patricia Williams 3 I am trying to break up into first name, last name and Customer ID. I have so far been able…
Sackling
  • 1,780
  • 5
  • 37
  • 71
1
vote
1 answer

StringTokenizer, JSON and comma's

I have a problem reading in strings with comma's within a JSON object within my Android project. A working JSON string is below: {"success": "[TG2301_Stoke Holy Cross, TF7439_Thornham Corner, TL8583_Thetford]"} But sometimes the place names have…
iaindownie
  • 1,046
  • 12
  • 28
1
vote
0 answers

Tokenizing the content of siblings in a DOM tree

I have a plan to traverse a dom tree in postorder fashion, then when its traversing through the siblings of each depth , for each sibling group, i want to get the number of elements in the text content for it. to make it clear, lets have a look at…
lonesome
  • 2,503
  • 6
  • 35
  • 61
1
vote
1 answer

How to handle with large dataset in spacy

I use the following code to clean my dataset and print all tokens (words). with open(".data.csv", "r", encoding="utf-8") as file: text = file.read() text = re.sub(r"[^a-zA-Z0-9ß\.,!\?-]", " ", text) text = text.lower() nlp =…
JukeboxHero
  • 105
  • 7
1
vote
3 answers

Java Performance issue for long length StringTokenizer

I have a program that read and process data in a raw text String using StringTokenizer Originally the StringTokenizer contains about 1,500 tokens and the program works fine. However the raw content increased and now it become about 12,000 tokens…
1
vote
2 answers

NLP Timer *How do I get the order of certain numbers in a string to use setting a timer?

import time import datetime from nltk_utils import bag_of_words, tokenize from nltk.tokenize.treebank import TreebankWordDetokenizer import multiprocessing from playsound import playsound def is_number(x): if type(x) == str: x =…
1
vote
1 answer

how to seperate a csv file using commas if it has null values and we need data corresponding to upper column?

My code is BufferedReader fileReader = new BufferedReader(new FileReader(strFileName)); while ((strLine = fileReader.readLine()) != null) { // [2011.06.28] based on OAP's mail, now ignore "quotations" …
Mudit Jha
  • 11
  • 2