### Question:
FileManager { public OutputStream newOutputStream(final String filepath, final boolean append) throws FileNotFoundException { final File file = new File(directory, filepath); return newOutputStream(file, append); } FileManager(final File rootDirectory); File createDirectory(final String directoryPath); File getDirectory(final String directoryPath); Set<File> listFilesInDirectory(final String directoryPath); Set<File> listFilesInDirectory(final File direc); File createFile(final String filepath); File createFile(final File file); boolean deleteFile(final String filepath); boolean deleteFile(final File file); InputStream newInputStream(final String filepath); InputStream newInputStream(final File file); OutputStream newOutputStream(final String filepath, final boolean append); OutputStream newOutputStream(final File file, final boolean append);  }### Answer:
@Test public void testNewOutputStreamFromPath() throws IOException { File file = new File(ROOT_DIRECTORY, FILE_PATH); assertFalse(file.exists()); file.createNewFile(); OutputStream os = fileManager.newOutputStream(FILE_PATH, true); os.write(5); os.flush(); os.close(); InputStream is = new FileInputStream(file); assertEquals(is.read(), 5); assertEquals(is.read(), -1); is.close(); }
@Test public void testNewOutputStreamFromFile() throws IOException { File file = new File(ROOT_DIRECTORY, FILE_PATH); assertFalse(file.exists()); file.createNewFile(); OutputStream os = fileManager.newOutputStream(file, true); os.write(5); os.flush(); os.close(); InputStream is = new FileInputStream(file); assertEquals(is.read(), 5); assertEquals(is.read(), -1); is.close(); }