Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Divide a String

 
mark issac
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Anybody can give suggestion how to Divide a big string into small part
Any Code-sample is Appreciated
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,
This question is not related to webservies. I am moving this to "java in general" forum, folks their can help you.
Cheers
Balaji
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depending on what you need to do, your best bets are either the String.split() method or the java.util.StringTokenizer class. Do you want to explain in a bit more detal what you want to accomplish?
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you know the positions you want to divide, then you can use substring
 
Lionel Badiou
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Marc,

Just a note : java.util.StringTokenizer class is depreciated.
So you may find your way through Enerst and Keith suggestions : use split(String) or substring(int) from String class.

Hope that helps,
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lionel Badiou:

Just a note : java.util.StringTokenizer class is depreciated.


The word is deprecated, and no, it's not. Go check if you don't believe me.
 
Lionel Badiou
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, my apologies Ernest Here is indeed the accurate status of StringTokenizer :

StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead.

Consequently, StringTokenizer is not deprecated as Ernest said, yet its use is discouraged

Best regards,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic