IOExt { public static List<String> readLines(File file) throws IOException { return readLines(file, Charset.defaultCharset()); } private  IOExt(); static void closeSilently(Closeable... closeables); static List<String> readLines(File file); static List<String> readLines(File file, Charset charset); static List<String> readLines(Reader source); static InputStream getFileResourceAsStream(String path);  }
@Test public void testReadLines() throws Exception { File file = File.createTempFile("junit", ".txt", new File("build")); try (Writer fwr = new FileWriter(file)) { fwr.write("line1\n"); fwr.write("line2"); } List<String> lines = IOExt.readLines(file); assertThat(lines).containsExactly("line1", "line2"); }