I have a txt file like this:
P 4 0 3 0 2 0 4 0 6 P 3 0 2 7 4 5 8 S 2 3 4 5 4 T 3 4 5 6 7 8 3
I read it into a string, and was trying to split the string. I need to split the String at P, S, T and store the string into an arraylist. I had this so far
List<String> list = new ArrayList<String>(Arrays.asList(content.split("P")));
for (int i = 0; i < list.size(); i++)
{
System.out.println(list.get(i));
}
and got
ArrayList size: 3
4 0 3 0 2 0 4 0 6
3 0 2 7 4 5 8 S 2 3 4 5 4 T 3 4 5 6 7 8 3
while i want the strings in the ArrayList to be something like
P 4 0 3 0 2 0 4 0 6
P 3 0 2 7 4 5 8
S 2 3 4 5 4
T 3 4 5 6 7 8 3
With each line representing a string. How can i go about doing something like this?