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

Elasticsearch: Find substring match

I want to perform both exact word match and partial word/substring match. For example if I search for "men's shaver" then I should be able to find "men's shaver" in the result. But in case case I search for "en's shaver" then also I should be able…
54
votes
8 answers

Why is StringTokenizer deprecated?

The Java documentation doesn't seem to mention anything about deprecation for StringTokenizer, yet I keep hearing about how it was deprecated long ago. Was it deprecated because it had bugs/errors, or is String.split() simply better to use…
donnyton
  • 5,874
  • 9
  • 42
  • 60
50
votes
10 answers

Convert time value to format “hh:mm Am/Pm” using Android

I am getting date value from database like "2013-02-27 06:06:30" using StringTokenizer I will get time separately like below String startTime = "2013-02-27 06:06:30"; StringTokenizer token = new StringTokenizer(startTime); String date1 =…
Android learner
  • 1,871
  • 4
  • 24
  • 36
41
votes
9 answers

Performance of StringTokenizer class vs. String.split method in Java

In my software I need to split string into words. I currently have more than 19,000,000 documents with more than 30 words each. Which of the following two ways is the best way to do this (in terms of performance)? StringTokenizer sTokenize = new…
JohnJohnGa
  • 15,446
  • 19
  • 62
  • 87
34
votes
1 answer

AutoCompleteTextView backed by CursorLoader

So I am having trouble extending the MultiAutoCompleteTextView and backing it with a CursorLoader, while simultaneously using a custom Tokenizer. The issue rises specifically with the mAdapter.setCursorToStringConverter(); call. The…
32
votes
14 answers

How to find a whole word in a String in Java?

I have a String that I have to parse for different keywords. For example, I have the String: "I will come and meet you at the 123woods" And my keywords are '123woods' 'woods' I should report whenever I have a match and where. Multiple…
Nikola Yovchev
  • 9,498
  • 4
  • 46
  • 72
29
votes
7 answers

Private Methods Over Public Methods

I was examining the StringTokenizer.java class and there were a few questions that came to mind. I noticed that the public methods which are to be used by other classes invoked some private method which did all of the work. Now, I know that one of…
lbj-ub
  • 1,425
  • 2
  • 19
  • 34
18
votes
5 answers

Difference between using StringTokenizer and String.split( )?

I've been using String[] split(String) of String class to split any string for some given delimiter, and it worked fine. However, now it is expected to re-factor the same logic with StringTokenizer. But what are the differences and benifits of using…
Satyendra
  • 1,635
  • 3
  • 19
  • 33
15
votes
2 answers

Using multiple delimiters with StringTokenizer

I'd like to know how I can use multiple delimiters with StringTokenizer in java. For example one of these !,*,/,^ will occur as a delimiter. Also there will only be one at a time.
nikhil
  • 8,925
  • 21
  • 62
  • 102
11
votes
3 answers

Most efficient way of splitting String in Java

For the sake of this question, let's assume I have a String which contains the values Two;.Three;.Four (and so on) but the elements are separated by ;.. Now I know there are multiple ways of splitting a string such as split() and StringTokenizer…
user92038111111
  • 191
  • 2
  • 2
  • 9
11
votes
4 answers

Regular expression for 6 digit number with optional 2 decimal digits

I need a regular expression for 6 digit number with optional 2 decimal digit Allowed values: .1 .11 0.11 10. 10.1 10.12 00.00 0.0 00.00 123456 12345 1234 123 12 1 0 0. 123. 123.55 123456.
Swapnil
  • 151
  • 1
  • 3
  • 9
10
votes
4 answers

how to split strings in objective c

How to split a string in objective-C? I am working on an short application that contains a date picker. I do display date get it from date picker and display it through a label. My main question is that how can I split the the date in to three…
jugnoo99
  • 103
  • 1
  • 1
  • 6
10
votes
5 answers

Java StringTokenizer, empty null tokens

I am trying to split a string into 29 tokens..... stringtokenizer won't return null tokens. I tried string.split, but I believe I am doing something wrong: String [] strings = line.split(",", 29); sample…
user69514
  • 26,935
  • 59
  • 154
  • 188
10
votes
1 answer

Tokenising a String containing empty tokens

I have a seemingly simple problem of splitting a comma separated String into tokens, whereby the output should include empty tokens in cases where: The first character in the String is a comma. The last character in the String is a comma. Two…
Adamski
  • 54,009
  • 15
  • 113
  • 152
9
votes
10 answers

How to replace tokens in a string without StringTokenizer

Given a string like so: Hello {FIRST_NAME}, this is a personalized message for you. Where FIRST_NAME is an arbitrary token (a key in a map passed to the method), to write a routine which would turn that string into: Hello Jim, this is a…
Yishai
  • 90,445
  • 31
  • 189
  • 263
1
2 3
41 42