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

How to train Tokenizer in OpenNLP?

I'm currently using the whitespace tokenizer in OpenNLP which tokenizes the sentence wherever it finds a whitespace. so, if I have a sentence like: My hobbies are reading books, magazines, Roller skating and playing football. Now, if I want to get…
user6384481
4
votes
1 answer

Returning the rest of the string with stringtokenizer

Looked for over an hour and cannot seem to find a way to implement this. I have a stringtokenizer object that is breaking apart a string(a mathematical expression). After reaching a certain point I want to be able to just take what is left of the…
user5270206
4
votes
1 answer

String tokenizer and piping symbol

String s = "test -||- testing again -|- test_1 -||- testing again_1"; StringTokenizer tokenizer = new StringTokenizer(s,"-|-"); System.out.println(tokenizer.countTokens()); while(tokenizer.hasMoreTokens()) { …
Thirumalai Parthasarathi
  • 4,541
  • 1
  • 25
  • 43
4
votes
1 answer

How to Parse the database Connection String for IPV4 and IPV6

Im trying to parse the bunch of url.I tried using the URI class in java but it is not perfect for the different set of strings. And also i have to do the parsing on IPV6.The input strings is given…
JAVA Beginner
  • 389
  • 3
  • 15
4
votes
4 answers

Does PL/SQL have an equivalent StringTokenizer to Java's?

I use java.util.StringTokenizer for simple parsing of delimited strings in java. I have a need for the same type of mechanism in pl/sql. I could write it, but if it already exists, I would prefer to use that. Anyone know of a pl/sql…
dacracot
  • 22,002
  • 26
  • 104
  • 152
4
votes
2 answers

How to find count and names of distinct characters in string in PL/SQL

I'm quite new to PL/SQL and I need to get the names and count of the distinct characters in a string. E.g. if I have a string str="helloexample", I need to get output of distinct characters in str, i.e. heloxamp. How can I do this?
iAmLearning
  • 1,153
  • 3
  • 15
  • 28
4
votes
4 answers

How to split a String with multiple delimiters in Java

I am trying to have the desired outputs like this: 555 555 5555 by using codes: public class Split { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub String phoneNumber = "(555)…
Venzentx
  • 487
  • 3
  • 6
  • 17
4
votes
3 answers

Get Position in Original String from `StringTokenizer`

I need to get the space-separated tokens in a string, but I also need to know the character position within the original string at which each token starts. Is there any way to do this with StringTokenizer. Also, as I understand it, this is a legacy…
Paul Manta
  • 30,618
  • 31
  • 128
  • 208
4
votes
1 answer

Split string with multiple delimiter including delimiters

I would like to split a string using multiple character delimiters, but I also want to store delimiters. My delimiters are ()+-*/ So for example, if I had a string 26+78(12*23)-16 I want to get 26 + 78 ( 12 * 23 ) - 16 each line as a…
Ersel Aker
  • 835
  • 9
  • 26
4
votes
2 answers

Java Tokenizer, separating strings

I don't know why I am struggling so badly with this but any help would be much appreciated. I am creating my own tokenizer that takes in a file with a list of commands, delimiters and values. It then outputs each "token" along with what type it…
btjordan23
  • 73
  • 1
  • 9
3
votes
3 answers

reading a long type from a text file in Java

i'm trying to read long types from a text file with using readLine() method of BufferedReader class and then i parse the first token (which is long type number) with using StringTokenizer but i'm facing with an exception error which is…
quartaela
  • 2,579
  • 16
  • 63
  • 99
3
votes
3 answers

Why is this string tokenizer making me cast to string?

I Think I broke this down to the most basic form. If not then I apologize and will try to edit it. Why in my while loop do I need to cast String for the FirstName if I already set the variable to be a String? Am I doing something wrong? I am try to…
Sackling
  • 1,780
  • 5
  • 37
  • 71
3
votes
2 answers

I want to search for a string using StringTokenizer but the string I'm looking for has a delimiter in it - Java

I have an external file named quotes.txt and I'll show you some contents of the file: 1 Everybody's always telling me one thing and out the other. 2 I love criticism just so long as it's unqualified praise. 3 The difference between 'involvement' and…
3
votes
2 answers

Python find offsets of a word token in a text

I wrote this function findTokenOffset that finds the offset of a given word in a pre-tokenized text (as a list of spaced words or according to a certain tokenizer). import re, json def word_regex_ascii(word): return…
loretoparisi
  • 15,724
  • 11
  • 102
  • 146
3
votes
1 answer

Getting Input on Different Lines with String Tokenizer

I have used Scanner(System.in) for a long time, but I am now transitioning to using BufferedReader and StringTokenizer because I heard it runs faster. I am trying to read an input (shown below) using StringTokenizer. I have looked at some posts but…
1 2
3
41 42