Results 1 to 4 of 4
- 02-12-2010, 01:25 PM #1
Member
- Join Date
- Feb 2010
- Posts
- 9
- Rep Power
- 0
Storing a string in StringTokenizer
Hi,
I am going to store a string in string tokenizer. But i am not getting the output what i think.
For example :
StringTokenizer st = new StringTokenizer("I born on 21.02.1995. So, now my age is 15.", ".");
I will get output as :
I born on 21
02
1995
So, now my age is 15.
But i want output as :
I born on 21.02.1995.
So, now my age is 15.
- 02-12-2010, 01:50 PM #2
Member
- Join Date
- Feb 2010
- Posts
- 6
- Rep Power
- 0
I think you need a \ before every special character that's not special, like the periods in the date, just like in an output if you need to output " you would do System.out.println(" blah blah blah \" blah \" blah");
Just a suggestion, idk
-
You really can't store a String with StringTokenizer as it has no capacity for storage, only for tokenizing.
Your output is as expected given your delimiter. If you want it to be different, I would recommend use of String#split(String regex) with an appropriate regexFor example :
StringTokenizer st = new StringTokenizer("I born on 21.02.1995. So, now my age is 15.", ".");
I will get output as :
I born on 21
02
1995
So, now my age is 15.
But i want output as :
I born on 21.02.1995.
So, now my age is 15.Last edited by Fubarable; 02-12-2010 at 02:02 PM.
-
Similar Threads
-
storing a string in an array
By tiyani in forum New To JavaReplies: 3Last Post: 08-12-2009, 07:25 PM -
Help with StringTokenizer!
By ookie833 in forum New To JavaReplies: 13Last Post: 12-14-2008, 04:09 PM -
StringTokenizer
By carderne in forum New To JavaReplies: 1Last Post: 01-26-2008, 08:19 PM -
StringTokenizer
By Java Tip in forum Java TipReplies: 0Last Post: 11-08-2007, 08:48 AM -
StringTokenizer
By Java Tip in forum Java TipReplies: 0Last Post: 11-03-2007, 09:24 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks