Looking at your string I assume that the different parts of the string are
seperate4d by a TAB character. If so do the following:
String line = "BATHROOM TOI 48157 Y DOVE BWASH MCDAMIA 375ML 6 NEW" ;
String[] parts = line.split("\\t");
//parts[0] = "BATHROOM TOI";
//parts[1] = "48157";
// etc. etc
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
No problem. And have fun.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
Is each data chunk given a certain amount of space to be written in and just filled in with blank spaces to pad a smaller value?
Phaelax
Practically a Posting Shark
858 posts since Mar 2004
Reputation Points: 92
Solved Threads: 51
well split() does take a regular expression, so why not just use that?
It looks for 2 or more spaces to be the delimiter.
String s = "BATHROOM TOI 48157 Y DOVE BWASH MCDAMIA 375ML 6 NEW" ;
String[] tokens = s.split(" {2,}?");
for(int i=0; i<tokens.length; i++)
System.out.println(tokens[i]);
Phaelax
Practically a Posting Shark
858 posts since Mar 2004
Reputation Points: 92
Solved Threads: 51
So start a new thread as this is a completely different question. P.S. that advice about StringTokenizer is not worth listening to. StringTokenizer has big problems with non-ASCII character sets among other limitations and drawbacks. It is effectively deprecated.
Killing this 4 year dead zombie now.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494