readLine from BufferedReader untill null returned. Add each line to array list. Is this what you need?
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
public class ReadToArrayList {
public static void main(String... args) throws Exception {
if (args.length < 1)
throw new IllegalArgumentException("Arguments: file");
BufferedReader reader = new BufferedReader (
new FileReader( new File(args[0])) );
// Read lines
ArrayList<String> lines = new ArrayList<String>();
try {
String line = null;
while((line = reader.readLine()) != null)
lines.add(line);
} finally {
reader.close();
}
// Process lines example
for(String line : lines)
System.out.println("> " + line);
}
}
well i have this piece of code which follows a split text body part.
newMessage = newTextMessage(splitText[0], splitText[1], splitText[2], splitText[3]);
textMessages.add(newMessage);
}
which would work as far as i can work it out, however i get an error;
"cannot find symbol - variable new message"
this implies i havnt declared the variable newMessage yeah? but i already have a method adding a method to an array list with .add(newMessage) being used.
its really confused me.