public class FSUtil
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
FSUtil.HANDLE_EXISTING |
| Modifier and Type | Field and Description |
|---|---|
private static java.util.regex.Pattern |
FILE_NAME_PATTERN |
| Constructor and Description |
|---|
FSUtil() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkThisIsAncestorOfOrSameAsThat(java.io.File ancestor,
java.io.File child)
Deprecated.
|
static boolean |
checkThisIsAncestorOfThat(java.io.File ancestor,
java.io.File child)
Deprecated.
|
static java.io.File |
getOutputFile(java.io.File outputRoot,
java.lang.String initialRelativePath,
FSUtil.HANDLE_EXISTING handleExisting,
java.lang.String suffix)
Deprecated.
|
static java.nio.file.Path |
getOutputPath(java.nio.file.Path outputRoot,
java.lang.String initialRelativePath,
FSUtil.HANDLE_EXISTING handleExisting,
java.lang.String suffix)
Given an output root and an initial relative path,
return the output file according to the HANDLE_EXISTING strategy
In the most basic use case, given a root directory "input",
a file's relative path "dir1/dir2/fileA.docx", and an output directory
"output", the output file would be "output/dir1/dir2/fileA.docx."
If HANDLE_EXISTING is set to OVERWRITE, this will not check to see if the output already exists,
and the returned file could overwrite an existing file!!!
If HANDLE_EXISTING is set to RENAME, this will try to increment a counter at the end of
the file name (fileA(2).docx) until there is a file name that doesn't exist.
|
static java.nio.file.Path |
resolveRelative(java.nio.file.Path p,
java.lang.String other)
Convenience method to ensure that "other" is not an absolute path.
|
@Deprecated
public static boolean checkThisIsAncestorOfThat(java.io.File ancestor,
java.io.File child)
@Deprecated
public static boolean checkThisIsAncestorOfOrSameAsThat(java.io.File ancestor,
java.io.File child)
@Deprecated
public static java.io.File getOutputFile(java.io.File outputRoot,
java.lang.String initialRelativePath,
FSUtil.HANDLE_EXISTING handleExisting,
java.lang.String suffix)
throws java.io.IOException
outputRoot - directory root for outputinitialRelativePath - initial relative path (including file name, which may be renamed)handleExisting - what to do if the output file existssuffix - suffix to add to files, can be nulljava.io.IOExceptiongetOutputPath(Path, String, HANDLE_EXISTING, String)public static java.nio.file.Path getOutputPath(java.nio.file.Path outputRoot,
java.lang.String initialRelativePath,
FSUtil.HANDLE_EXISTING handleExisting,
java.lang.String suffix)
throws java.io.IOException
outputRoot - root directory into which to put the pathinitialRelativePath - relative path including file ("somedir/subdir1/file.doc")handleExisting - policy for what to do if the output path already existssuffix - suffix to add to the output pathjava.io.IOExceptionpublic static java.nio.file.Path resolveRelative(java.nio.file.Path p,
java.lang.String other)
p - other - java.lang.IllegalArgumentException - if "other" is an absolute path