Reading A File Into A List - With JDK 1.7 …And Without Streams 📎
import java.io.IOException;
import static java.nio.charset.Charset.*;
import static java.nio.file.Files.*;
import static java.nio.file.Paths.*;
import java.util.List;
public class FileReader {
public static void read(String file) throws IOException{
List<String> allLines = readAllLines(get(file), defaultCharset());
for (String line : allLines) {
System.out.println(line);
}
}
public static void main(String[] args) throws IOException {
read("./readme.txt");
}
}
[Thanks to @Sander_Mak for the idea]