List of utility methods to do File System
String | toSystemPath(String rawpath) As the declared paths in this testcase might be actual paths on the system running these tests, the expected paths should be cleaned up to represent the actual system paths. Path path = FileSystems.getDefault().getPath(rawpath); if (Files.exists(path)) { try { path = path.toRealPath(); } catch (IOException e) { path = path.toAbsolutePath(); e.printStackTrace(); } else { path = path.toAbsolutePath(); return path.toString(); |
void | zipDirectoryOrFile(String level, Path target, FileSystem zipFileFileSystem) zip Directory Or File Files.list(target).forEach(new Consumer<Path>() { @Override public void accept(Path entry) { try { Files.copy(entry, zipFileFileSystem.getPath(level + entry.getFileName())); if (Files.isDirectory(entry, new LinkOption[] {})) { zipDirectoryOrFile(level + entry.getFileName() + "/", entry, zipFileFileSystem); } catch (IOException iOException) { }); |