UnixPath { public Optional<byte[]> readBytesIfExists() { try { return Optional.of(Files.readAllBytes(path)); } catch (NoSuchFileException ignored) { return Optional.empty(); } catch (IOException e) { throw new UncheckedIOException(e); } } UnixPath(Path path);  UnixPath(String path); Path toPath(); UnixPath resolve(String relativeOrAbsolutePath); UnixPath getParent(); String getFilename(); boolean exists(); String readUtf8File(); Optional<String> readUtf8FileIfExists(); byte[] readBytes(); Optional<byte[]> readBytesIfExists(); UnixPath writeUtf8File(String content, OpenOption... options); UnixPath writeBytes(byte[] content, OpenOption... options); UnixPath atomicWriteUt8(String content); UnixPath atomicWriteBytes(byte[] content); String getPermissions(); UnixPath setPermissions(String permissions); String getOwner(); UnixPath setOwner(String owner); String getGroup(); UnixPath setGroup(String group); Instant getLastModifiedTime(); UnixPath updateLastModifiedTime(); UnixPath setLastModifiedTime(Instant instant); FileAttributes getAttributes(); Optional<FileAttributes> getAttributesIfExists(); UnixPath createNewFile(); UnixPath createNewFile(String permissions); UnixPath createParents(); UnixPath createDirectory(String permissions); UnixPath createDirectory(); boolean isDirectory(); boolean isSymbolicLink(); boolean deleteRecursively(); UnixPath deleteIfExists(); Stream<UnixPath> listContentsOfDirectory(); UnixPath atomicMove(Path to); boolean moveIfExists(Path to); UnixPath createSymbolicLink(Path link); FileSnapshot getFileSnapshot(); @Override String toString();  }
@Test public void readBytesIfExists() { UnixPath path = new UnixPath(fs.getPath("example.txt")); assertFalse(path.readBytesIfExists().isPresent()); path.writeBytes(new byte[]{42}); assertArrayEquals(new byte[]{42}, path.readBytesIfExists().get()); }