public void testCreateParentDirs_root() throws IOException { File file = root(); assertNull(file.getParentFile()); assertNull(file.getCanonicalFile().getParentFile()); Files.createParentDirs(file); }
public void testCreateParentDirs_relativePath() throws IOException { File file = file("nonexistent.file"); assertNull(file.getParentFile()); assertNotNull(file.getCanonicalFile().getParentFile()); Files.createParentDirs(file); }
public void testLineReading() throws IOException { File temp = createTempFile(); assertNull(Files.readFirstLine(temp, Charsets.UTF_8)); assertTrue(Files.readLines(temp, Charsets.UTF_8).isEmpty()); PrintWriter w = new PrintWriter(Files.newWriter(temp, Charsets.UTF_8)); w.println("hello"); w.println(""); w.println(" world "); w.println(""); w.close(); assertEquals("hello", Files.readFirstLine(temp, Charsets.UTF_8)); assertEquals( ImmutableList.of("hello", "", " world ", ""), Files.readLines(temp, Charsets.UTF_8)); assertTrue(temp.delete()); }
public void testCreateParentDirs_root() throws IOException { File file = root(); assertNull(file.getParentFile()); assertNull(file.getCanonicalFile().getParentFile()); Files.createParentDirs(file); }
public void testCreateParentDirs_relativePath() throws IOException { File file = file("nonexistent.file"); assertNull(file.getParentFile()); assertNotNull(file.getCanonicalFile().getParentFile()); Files.createParentDirs(file); }
public void testLineReading() throws IOException { File temp = createTempFile(); assertNull(Files.readFirstLine(temp, Charsets.UTF_8)); assertTrue(Files.readLines(temp, Charsets.UTF_8).isEmpty()); PrintWriter w = new PrintWriter(Files.newWriter(temp, Charsets.UTF_8)); w.println("hello"); w.println(""); w.println(" world "); w.println(""); w.close(); assertEquals("hello", Files.readFirstLine(temp, Charsets.UTF_8)); assertEquals(ImmutableList.of("hello", "", " world ", ""), Files.readLines(temp, Charsets.UTF_8)); assertTrue(temp.delete()); }