I am buffering a text file of into 'arraylist lines' i then need to split each line into a new arrayList parts, so that i can find information from each line and add the data to a model i have built, the reason i am using arrayLists is because of there expandable properties, meaning i wont need to worry about the size of either the line or the text file.
the code is below:
try(BufferedReader buffer =
new BufferedReader(new FileReader("src/Sample.txt")))
{
String currentLine;
ArrayList<String> lines = new ArrayList<String>();
ArrayList<String> parts = new ArrayList<String>();
//ListIterator<String> lineItr = lines.listIterator();
while((currentLine = buffer.readLine()) != null)
{
lines.add(currentLine);
for(String line : lines)
{
parts.addAll(line.split("\\s+"));
}
//lineItr.next();
//lineItr.set(currentLine);
//System.out.println(lineItr.next());
}
}
catch(IOException e)
{
e.printStackTrace();
}
}
i am having my troubles with parts.addAll(line.split("\s+"); i do not understand why the statement does not iterate through lines, splitting and adding each part of the string to the parts array list, am i misunderstanding something here?
thanks Babble