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

Infinite Loop in Java

So I'm trying to look at an input, and count words that fit a certain criteria (or rather, excluding words that I don't want to count). The error is in the following code: BufferedReader br; BufferedWriter bw; String line; int…
muttley91
  • 12,278
  • 33
  • 106
  • 160
1
vote
0 answers

How do I turn Java code into spark code?

a.txt: {27|2|0|1|49|6|N926 50|2|0|1|49|10|N760 36|1|0|1|50|8|nncd} String Tokenizing with Java code is easy. But I do not know String Tokenizing in spark code. How can I do StringTokenizing based on '|' with spark code? Below my Java code (label…
김태수
  • 29
  • 4
1
vote
2 answers

java StringTokenizer - can nextToken return null?

Is there any case where StringTokenizer.nextToken will return null? I'm trying to debug a NullPointerException in my code, and so far the only possibility I've found is that the string returned from nextToken() returned null. Is that a possibility?…
duduamar
  • 3,816
  • 7
  • 35
  • 54
1
vote
2 answers

String Tokenizer/Regex to find email address/IP Address in a file

I have a document with lines containing email addresses and IP addresses. I need to split the document in terms of email addresses and IP addresses to store each IP/email address or words in the file in an array. Is there a way to use regex/String…
user100000001
  • 35
  • 1
  • 2
  • 8
1
vote
1 answer

validate null string while using tokenizer

I have a String like this: String sample = "a|b||d|e"; and I'm trying to split the string with tokenizer StringTokenizer tokenizer = new StringTokenizer(sample, "|"); String a = tokenizer.nextToken(); String b = tokenizer.nextToken(); String c =…
Kishor kumar R
  • 195
  • 2
  • 17
1
vote
0 answers

fast way to tokenize data in Python like TfidfVectorizer does

i used TfidfVectoriser to create tf-idf matrix from sklearn.feature_extraction.text import TfidfVectorizer transformer = TfidfVectorizer(smooth_idf=False,stop_words=stopwords.words('english')) tfidf =…
Slavka
  • 1,070
  • 4
  • 13
  • 28
1
vote
1 answer

java token if statement

I have a problem with an ifstatement in a StringTokenizer method i think it is due to it being a char array, I have tryed to convert it but it seems not to work any help would be aprecheated thanks harry. char[] password =…
Harry Martland
  • 604
  • 2
  • 14
  • 26
1
vote
3 answers

Storing an array of strings without initializing the size

Background: This program reads in a text file and replaces a word in the file with user input. Problem: I am trying to read in a line of text from a text file and store the words into an array. Right now the array size is hard-coded with an number…
1
vote
1 answer

Why am I getting a NoSuchElementException?

I'm sure this just comes down to me not understanding StringTokenizer, but I can't find an answer for this anywhere. Why am I getting this error? import java.io.*; import java.util.StringTokenizer; import java.util.Scanner; public class…
Seth Myers
  • 53
  • 1
  • 1
  • 8
1
vote
4 answers

Ignore parentheses with string tokenizer?

I have an input that looks like: (0 0 0) I would like to ignore the parenthesis and only add the numbers, in this case 0, to an arraylist. I am using scanner to read from a file and this is what I have so far transitionInput = data.nextLine(); …
Raptrex
  • 3,915
  • 10
  • 49
  • 61
1
vote
2 answers

Does StringTokenizer have any max length on tokens?

I have a piece of code that has been working for years until today. After debugging I realized that last token it not collected correctly. I think is because of his length (more than 10k chars). Code: StringTokenizer tokens = new…
daniherculano
  • 373
  • 1
  • 9
  • 26
1
vote
2 answers

How can i compare the value of a string response against version of installed app

I'm trying to write a auto update using Volley library and Dropbox API. I've set it up so that it reads a blog page and finds this chunk of code: if (response != null) { boolean resp = response.contains("
Mark Harrop
  • 192
  • 1
  • 14
1
vote
3 answers

Apache Solr Tokenizers

I am using Apache Solr as my semantic search engine. In which users can type anything and I have to retrieve using relevant results using words. I want to split string in tokens. Example: "actorsfrommumbai" -> "actors from mumbai" How can I achieve…
1
vote
4 answers

countTokens() always returns 1 with user input

Before we begin, I don't believe this is a repeat question. I've read the question entitled StringTokenzer countTokens() returns 1 with any string, but that does not address the fact that a properly delimited string is counted correctly, but a…
Craig K.
  • 13
  • 5
1
vote
2 answers

java calculator without stack or arraylist

java calculator without stack or arraylist