IO { public static Path toPath(String firstPart, String... more) { FileSystem fileSystem = defaultFsThreadLocal.get(); if (fileSystem == null) { fileSystem = defaultFs; } return fileSystem.getPath(firstPart, more); } private  IO(); static void deleteFile(Path file, boolean throwException, String loggerModule); static void deleteFile(Path file, boolean throwException, Logger context); static void closeQuietly(ResultSet rs); static void closeQuietly(Statement stmt); static void copyDirectoryOrFile(@Nonnull final Path from,
                                           @Nonnull final Path to,
                                           boolean copyInto); static void copyDirectoryOrFile(@Nonnull final Path from,
                                           @Nonnull final Path to,
                                           boolean copyInto,
                                           @Nullable final DirectoryStream.Filter<Path> filter); static Path relativeFile(Path relativeToDirectory, Path fileOrDirectory, Path newRelativeTo); static void moveDirectoryOrFile(final Path from, final Path to, boolean copyInto); static boolean isEmptyDir(Path dir); static void deleteFileOrDirectory(Path path); static void deleteFileOrDirectory(Path path, final boolean ignoreErrors); static void touch(Path file); static void touch(Path file, FileTime timestamp); static Path toPath(String firstPart, String... more); static Path toPath(URI uri); static void setFileSystem(FileSystem newFileSystem); static void setFileSystemThreadLocal(FileSystem newFileSystem); static URL toURL(Path textFile); static URL toURL(URI uri); static InputStream newInputStream(Path file); static BufferedReader newBufferedReader(Path path, Charset cs); static final DirectoryStream.Filter<Path> DIRECTORIES_FILTER; static final DirectoryStream.Filter<Path> FILES_FILTER; }
@Test public final void testToPath() throws Exception { final Path path = IO.toPath("part"); assertEquals(getFileUri(), path.toUri()); final URI rootUri = temporaryFolder.getRoot().toURI(); final URI zipFsUri = new URI("jar:" + rootUri + "x.zip"); IO.setFileSystemThreadLocal(null); final FileSystem zipFileSystem = FileSystems.newFileSystem(zipFsUri, Collections.singletonMap("create", "true")); IO.setFileSystem(zipFileSystem); final Path zipPath = IO.toPath("part"); assertEquals("jar:" + rootUri + "x.zip!/part".replaceAll("/+", "/"), zipPath.toUri().toString().replaceAll("/+", "/")); }