-
String Splitting
Hi,
I have a text file and I read it by buffered reader ..
but when I split each line by split() method I face a problem
that it doesn't split the line as I want, here's an example :
*let the last line of the text above is read and stored in a string named "A".
String [] words = A.split("[,. ]");
then I wanted to determine location of each word in this string.. (e.g the word "that" is stored in cell [0] in the array)
but when I was working and trying it, it gave me the word "here's" in the cell [10] and I want it in cell [9]..
this's the problem, I looked everywhere but couldn't find solution :( !!
Thanks :)
-
Code:
String s =
"that it doesn't split the line as I want, here's an example :";
String[] x = s.split("\\s");
System.out.println("x: " + java.util.Arrays.toString(x));