Given a string that isn\'t too long, what is the best way to read it line by line?
I know you can do:
BufferedReader reader = new BufferedReader(new
There is also Scanner. You can use it just like the BufferedReader:
BufferedReader
Scanner scanner = new Scanner(myString); while (scanner.hasNextLine()) { String line = scanner.nextLine(); // process the line } scanner.close();
I think that this is a bit cleaner approach that both of the suggested ones.