public final class FileUtils extends Object
FileSystems| Modifier and Type | Method and Description |
|---|---|
static String |
getRelativePathName(Path root,
Path path)
Returns a relative and normalized name for a
Path. |
static Path |
normalize(Path path)
Returns a normalized
Path. |
static InputStream |
toInputStream(Path path)
Converts a the contents of a
Path to a InputStream. |
static InputStream |
toInputStream(Path path,
Predicate<Path> filter)
Converts a the contents of a
Path to a InputStream. |
public static String getRelativePathName(Path root, Path path)
Path. This method ensures that directories have a single trailing slash in their namepublic static Path normalize(Path path)
Path. In the case of directories, it returns the Path as it was passed in. In the case of files, it returns a Path representing the root of a
filesystem mounted using FileSystems.newFileSystem(java.net.URI, java.util.Map<java.lang.String, ?>).path - the Path to normalizedpublic static InputStream toInputStream(Path path)
Path to a InputStream. If the Path is a directory, compresses the full contents of the directory into the stream. If the Path
is a file, the contents of the file are examined using FileSystems.newFileSystem(java.net.URI, java.util.Map<java.lang.String, ?>) starting at the root. This allows both exploded and compressed artifacts to be used interchangeably.path - a Path representing either a compressed or exploded artifactInputStream containing the compressed contents of the pathpublic static InputStream toInputStream(Path path, Predicate<Path> filter)
Path to a InputStream. If the Path is a directory, compresses the full contents of the directory into the stream. If the Path
is a file, the contents of the file are examined using FileSystems.newFileSystem(java.net.URI, java.util.Map<java.lang.String, ?>) starting at the root. This allows both exploded and compressed artifacts to be used interchangeably.path - a Path representing either a compressed or exploded artifactfilter - a Predicate to filter the Paths that will be added to the InputStreamInputStream containing the compressed contents of the pathCopyright © 2016 Pivotal Software, Inc.. All rights reserved.