Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieve delimetted value from String

 
aakash bhatt
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my String , I have value as String vTest = "ABC#XYZ#PQR#STV"
How do i retrieve the value ABC, XYZ each by each which is delimetted by #
Thanks,
aakash
 
Nigel Browne
Ranch Hand
Posts: 703
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use StringTokenizer
 
Jeff Allison
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While StringTokenizer will work, the split method works for simple strings and delimiters like this. See <http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#split(java.lang.String)>
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And in JDK 5 you can try Scanner. So many ways to solve one problem!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic