Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Durril Jansen   on Nov 26 In Java Category.

  
Question Answered By: Hoor Khan   on Nov 26

someString.split("\n");
The only thing is that it eats the \n in your String.

One thing that you have to be careful of how you input to that String.
It could be more than possible for \r or \n\r to creep into your input
statements (well in my experience they can). So you might need to
process the line  turning all \n and \r to \n\r and then split  on \n\r
(or turn \r and \n\r to \n) ... although your case might be specific
enough that you don't need to.

As for the screams to use StringTokenizer, I try not to use
StringTokenizer if I can at all afford not to. I find it slow and
cumbersome to use in anything but the most simplistic of cases, and even
then the simple cases can be almost always solved with split();

Share: 

 

This Question has 7 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on breaking a String into a String[] Or get search suggestion and latest updates.


Tagged: