FileUtils { public String getFileAsString(final File file) { return new String(this.readFile(file)); }  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 getFileAsString() throws IOException { Path path = Paths.get(rootProjectDir.getRoot().toPath().toString(), "file.file"); Files.write(path, "Test".getBytes(Charset.defaultCharset())); String content = FileUtils.INSTANCE.getFileAsString(path.toFile()); assertNotNull(content); assertEquals("Test", content); }
@Test void getFileNonexistent() throws IOException { Path path = Paths.get(rootProjectDir.getRoot().toPath().toString(), "file.file"); assertThrows(EntityBuilderException.class, () -> FileUtils.INSTANCE.getFileAsString(path.toFile())); }