This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Splitting a string

 
Ben Roy
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was just posting a question regarding the java.lang.String.split() method when I figured out that I was using 1.3 and it's only available in 1.4. So that leaves me the question of whether there is some way to do this (split a comma separated list into an array) in 1.3 other than manually write my own function to do it. Anyone got a quick solution?
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben
You'll want to check out the StringTokenizer class. It'll give you an enumeration that you can iterate over and store into an array.
There may be another way out there but this was the first that came to mind.
hope that helps


------------------
Dave
Sun Certified Programmer for the Java� 2 Platform
 
deadsea
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the split function that is found in this class: http://ostermiller.org/utils/StringHelper.html
 
Ben Roy
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You know it's kind of funny how sometimes the problem isn't the language...
One method was reading a recordset and dumping the information in a string, then the other was converting from a string to array. Duh...I hadn't even written the first yet, so I just rethought it and made it return String[] instead. Solved all my conversion problems and works great. Thanks for the suggestions though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic