public class FSUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
FSUtil.HANDLE_EXISTING |
Constructor and Description |
---|
FSUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
checkThisIsAncestorOfOrSameAsThat(File ancestor,
File child)
Deprecated.
|
static boolean |
checkThisIsAncestorOfThat(File ancestor,
File child)
Deprecated.
|
static File |
getOutputFile(File outputRoot,
String initialRelativePath,
FSUtil.HANDLE_EXISTING handleExisting,
String suffix)
Deprecated.
|
static Path |
getOutputPath(Path outputRoot,
String initialRelativePath,
FSUtil.HANDLE_EXISTING handleExisting,
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 Path |
resolveRelative(Path p,
String other)
Convenience method to ensure that "other" is not an absolute path.
|
@Deprecated public static boolean checkThisIsAncestorOfThat(File ancestor, File child)
@Deprecated public static boolean checkThisIsAncestorOfOrSameAsThat(File ancestor, File child)
@Deprecated public static File getOutputFile(File outputRoot, String initialRelativePath, FSUtil.HANDLE_EXISTING handleExisting, String suffix) throws 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 nullIOException
getOutputPath(Path, String, HANDLE_EXISTING, String)
public static Path getOutputPath(Path outputRoot, String initialRelativePath, FSUtil.HANDLE_EXISTING handleExisting, String suffix) throws 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 pathIOException
public static Path resolveRelative(Path p, String other)
p
- other
- IllegalArgumentException
- if "other" is an absolute pathCopyright © 2007–2023 The Apache Software Foundation. All rights reserved.