FileUtils { public OutputStream getOutputStream(final File file) { final OutputStream stream; try { stream = Files.newOutputStream(file.toPath()); } catch (IOException e) { throw new EntityBuilderException("Could not write to file " + file.getPath(), e); } return stream; }  InputStream getInputStream(final File file); OutputStream getOutputStream(final File file); String getFileAsString(final File file); static void closeQuietly(java.io.Closeable closeable); static List<File> collectFiles(final String folder, final String extension); static File findConfigFileOrDir(final File baseDir, final String fileOrDirName); static final boolean POSIX_ENABLED; static final FileUtils INSTANCE; }
@Test void getOutputStream() throws IOException { Path path = Paths.get(rootProjectDir.getRoot().toPath().toString(), "file.file"); OutputStream stream = FileUtils.INSTANCE.getOutputStream(path.toFile()); assertNotNull(stream); stream.close(); Files.delete(path); }
@Test void getOutputStreamMissingPath() { Path path = Paths.get(rootProjectDir.getRoot().toPath().toString(), "test", "file.file"); assertThrows(EntityBuilderException.class, () -> FileUtils.INSTANCE.getOutputStream(path.toFile())); }