### Question:
SafeFiles { public static void write(final byte[] data, final Path path) throws IOException { try (final SafeOutputStream out = createAtomicFile(path)) { out.write(ByteBuffer.wrap(data)); out.commit(); } } private  SafeFiles(); static void rename(final Path oldName, final Path newName); static void ensureDirectoryExists(final Path path); @Nonnegative static int fsyncRecursive(final Path root); static void fsync(final Path path); static void writeUTF8(final String value, final Path path); static void write(final byte[] data, final Path path); @Nonnull static SafeOutputStream createAtomicFile(final Path path); static void deleteIfExistsQuietly(final Path path);  }### Answer:
@Test public void write_direct_ok() throws IOException { final Path path = root.resolve("foo.bin"); final byte[] wrote = "hello world".getBytes(Charsets.UTF_8); SafeFiles.write(wrote, path); checkFilePermissions(path); final byte[] read = com.google.common.io.Files.toByteArray(path.toFile()); Assert.assertArrayEquals(wrote, read); Assert.assertEquals("no stray files", 1, Directories.count(root)); }