Sep
23
|
The readLine() method of java.io.BufferedReader class reads the next line from a text file. When it reaches the end of the file it will return null.
List<String> lines = new ArrayList<String>(); BufferedReader in = new BufferedReader(new FileReader(filename)); String line = null; while (null!=(line=in.readLine())) { lines.add(line); } in.close(); // lines will now contain the contents of the file
Leave a Reply
You must be logged in to post a comment.