public class Files2 extends Object
| Constructor and Description |
|---|
Files2() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addFileToZip(InputStream sourceFile,
Path destZipFile,
String destFile,
CopyOption... copyOptions) |
static void |
addFileToZip(Path sourceStream,
Path destZipFile,
String destFile,
CopyOption... copyOptions) |
static void |
chmodAddReadExecute(Path path) |
static void |
chmodAddReadWrite(Path path) |
static void |
chmodReadExecute(Path path)
Deprecated.
|
static void |
chmodReadOnly(Path path) |
static void |
chmodReadWrite(Path path)
Deprecated.
|
static void |
chmodSetReadOnly(Path path) |
static Path |
copyArtifactToDirectory(Path sourceDir,
String artifactId,
Path dest) |
static void |
copyDirectoryContent(Path srcDir,
Path destDir)
Copy content for
srcDir to destDir |
static Path |
copyToDirectory(Path srcFile,
Path destDir)
Copy given
srcFile to given destDir. |
static void |
deleteDirectory(Path dir)
Delete given
dir and its content (rm -rf). |
static void |
dump(Path path)
For debugging purpose.
|
static Path |
findArtifact(Path srcDir,
String artifactId)
Find jar file with name beginning with given
artifactId in given srcDir. |
static Path |
findArtifact(Path srcDir,
String artifactId,
String type)
Find a file matching
$artifactId*$type in the given srcDir. |
static Path |
findUniqueChildDirectory(Path srcDir) |
static Path |
findUniqueDirectoryBeginningWith(Path srcDir,
String pattern) |
static Path |
findUniqueFolderBeginningWith(Path source,
String pattern)
Deprecated.
|
static void |
untgz(Path tgzFile,
Path destDir)
TODO recopy file permissions
Uncompress the specified tgz file to the specified destination directory.
|
static void |
untgz(String tgzFilename,
String destDirname)
Uncompress the specified tgz file to the specified destination directory.
|
static void |
unzip(Path zipFile,
Path destDir) |
static void |
unzip(String zipFilename,
String destDirname)
Unzips the specified zip file to the specified destination directory.
|
static void |
unzipSubDirectoryIfExists(Path zipFile,
String zipSubPath,
Path destDir)
Copy every file of given
zipFile beginning with given zipSubPath to destDir |
static Path |
unzipSubFileIfExists(Path zipFile,
String zipSubFilePath,
Path destDir)
Copy the given
zipSubFilePath of the given zipFile into the destDir if this sub file exists. |
static Path |
unzipSubFileIfExists(Path zipFile,
String zipSubFilePath,
Path destDir,
boolean trimSourcePath)
Copy the given
zipSubFilePath of the given zipFile into the destDir if this sub file exists. |
public static void deleteDirectory(@Nonnull Path dir) throws RuntimeIOException
dir and its content (rm -rf).dir - RuntimeIOExceptionpublic static void chmodReadOnly(@Nonnull Path path) throws RuntimeIOException
RuntimeIOExceptionpublic static void chmodSetReadOnly(@Nonnull Path path) throws RuntimeIOException
RuntimeIOExceptionpublic static void chmodAddReadExecute(@Nonnull Path path) throws RuntimeIOException
RuntimeIOExceptionpublic static void chmodAddReadWrite(@Nonnull Path path) throws RuntimeIOException
RuntimeIOException@Deprecated public static void chmodReadExecute(Path path) throws RuntimeIOException
chmodAddReadExecute(java.nio.file.Path)RuntimeIOException@Deprecated public static void chmodReadWrite(Path path) throws RuntimeIOException
chmodAddReadWrite(java.nio.file.Path)RuntimeIOExceptionpublic static void unzip(String zipFilename, String destDirname) throws RuntimeIOException
zipFilename - the name of the zip file to extractdestDirname - the directory to unzip toRuntimeIOException@Nullable public static Path unzipSubFileIfExists(@Nonnull Path zipFile, @Nonnull String zipSubFilePath, @Nonnull Path destDir) throws RuntimeIOException
zipSubFilePath of the given zipFile into the destDir if this sub file exists.zipFile - the source zip file (e.g. path/to/app.warzipSubFilePath - sub file path in the zip file (e.g. /WEB-INF/web.xmldestDir - RuntimeIOException@Nullable public static Path unzipSubFileIfExists(@Nonnull Path zipFile, @Nonnull String zipSubFilePath, @Nonnull Path destDir, boolean trimSourcePath) throws RuntimeIOException
zipSubFilePath of the given zipFile into the destDir if this sub file exists.zipFile - the source zip file (e.g. path/to/app.warzipSubFilePath - sub file path in the zip file (e.g. /WEB-INF/web.xmldestDir - trimSourcePath - indicates if the source path should be trimmed creating the dest file (e.g. should WEB-INF/web.xml be copied as
dest-dir/WEB-INF/web.xml or as dest-dir/web.xml)RuntimeIOExceptionpublic static void unzipSubDirectoryIfExists(@Nonnull Path zipFile, @Nonnull String zipSubPath, @Nonnull Path destDir) throws RuntimeIOException
zipFile beginning with given zipSubPath to destDirzipFile - zipSubPath - must start with a "/"destDir - RuntimeIOExceptionpublic static void addFileToZip(@Nonnull Path sourceStream, @Nonnull Path destZipFile, @Nonnull String destFile, CopyOption... copyOptions)
public static void addFileToZip(@Nonnull InputStream sourceFile, @Nonnull Path destZipFile, @Nonnull String destFile, CopyOption... copyOptions)
public static void unzip(@Nonnull Path zipFile, @Nonnull Path destDir) throws RuntimeIOException
RuntimeIOExceptionpublic static void untgz(String tgzFilename, String destDirname) throws RuntimeIOException
tgzFilename - the name of the zip file to extractdestDirname - the directory to unzip toRuntimeIOExceptionpublic static void untgz(@Nonnull Path tgzFile, @Nonnull Path destDir) throws RuntimeIOException
tgzFile - the name of the zip file to extractdestDir - the directory to unzip toRuntimeIOExceptionpublic static void dump(@Nonnull Path path) throws RuntimeIOException
stderrpath - IOExceptionRuntimeIOExceptionpublic static void copyDirectoryContent(@Nonnull Path srcDir, @Nonnull Path destDir) throws RuntimeIOException
srcDir to destDirsrcDir - destDir - RuntimeIOException@Nonnull public static Path copyToDirectory(@Nonnull Path srcFile, @Nonnull Path destDir) throws RuntimeIOException
srcFile to given destDir.srcFile - destDir - destination directory, must existRuntimeIOException@Nonnull public static Path copyArtifactToDirectory(@Nonnull Path sourceDir, @Nonnull String artifactId, @Nonnull Path dest) throws RuntimeIOException
RuntimeIOException@Nonnull public static Path findArtifact(@Nonnull Path srcDir, @Nonnull String artifactId) throws RuntimeIOException, IllegalStateException
artifactId in given srcDir.srcDir - artifactId - RuntimeIOExceptionIllegalStateExceptionfindArtifact(java.nio.file.Path, String, String)@Deprecated @Nonnull public static Path findUniqueFolderBeginningWith(@Nonnull Path source, @Nullable String pattern) throws RuntimeIOException, IllegalStateException
findUniqueDirectoryBeginningWith(java.nio.file.Path, String)@Nonnull public static Path findUniqueDirectoryBeginningWith(@Nonnull Path srcDir, @Nonnull String pattern) throws RuntimeIOException, IllegalStateException
srcDir - pattern - RuntimeIOExceptionIllegalStateException - More or less than 1 child dir found@Nonnull public static Path findUniqueChildDirectory(@Nonnull Path srcDir) throws RuntimeIOException, IllegalStateException
srcDir - RuntimeIOExceptionIllegalStateException - More or less than 1 child dir found@Nonnull public static Path findArtifact(@Nonnull Path srcDir, @Nonnull String artifactId, @Nonnull String type) throws RuntimeIOException, IllegalStateException
$artifactId*$type in the given srcDir.srcDir - artifactId - type - IllegalStateException - More or less than 1 matching artifact foundRuntimeIOExceptionCopyright © 2013-2014. All Rights Reserved.