This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization 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