Modifier and Type | Field and Description |
---|---|
static String |
ROOT |
static String |
ROOT_UNIX |
static String |
ROOT_WINDOWS |
static String |
ROOT_WINDOWS_NETWORK |
Modifier and Type | Method and Description |
---|---|
static List<File> |
expandFiles(File currentDirectory,
String... paths)
Expands files if necessary, meaning that input files with wildcards are
expanded.
|
static List<File> |
expandFiles(String... paths)
Expands files if necessary, meaning that input files with wildcards are
expanded.
|
static File |
getDirectoryOfClassFile(Class<?> clazz)
This method returns the parent directory of a given class.
|
static File |
getDirectoryOfClassFile(String className)
This method returns the parent directory of a given class.
|
static FilenameFilter |
getFileNameFilter(String name)
Returns a file name filter for the specified name.
|
static File |
getOutputDirectoryGivenClass(Class<?> clazz)
This method returns the output directory of a given class.
|
static List<String> |
getPathElements(File file)
Returns all path elements of the given
file . |
static String |
getRelativePath(File root,
File file)
Returns the path of the given
file relative to the given
root . |
static File |
getUserDir()
Returns the user's current working directory taken from the system
property "user.dir".
|
static boolean |
isWildcardFileName(String name)
Returns true if the given name or path contains unescaped wildcard
characters.
|
static File |
toAbsoluteFile(File currentDirectory,
File file)
Returns an absolute file for the given input file, resolving relative
paths on the basis of the given
currentDirectory . |
static List<File> |
toList(File... files)
Returns the specified files in a new mutable array list.
|
public static final String ROOT_UNIX
public static final String ROOT_WINDOWS
public static final String ROOT_WINDOWS_NETWORK
public static File getUserDir()
System.getProperties()
public static List<File> toList(File... files)
Arrays.asList(Object...)
but the returned list is expandable.files
- the files to add to a new listpublic static String getRelativePath(File root, File file)
file
relative to the given
root
.
The relative path is evaluated as follows:
root
is the same as file
, "." is returnedroot
is the direct parent directory of file
, the
simple file name is returnedroot
is a non-direct parent directory of file
, the
relative path from root
to file
is returnedroot
is not parent directory of file
, the relative
path is the path from root
to the common ancestor and then to
file
root
is not parent directory of file
and the only
common ancestor of the two is the root directory, the absolute path of
file
is returnedroot
- the root directory for the relative pathfile
- the file whose path should be returnedfile
relative to root
public static File toAbsoluteFile(File currentDirectory, File file)
currentDirectory
. If the given
file
represents an absolute path or a variable, it is returned
unchanged. If currentDirectory==null
,
File.getAbsoluteFile()
is returned.currentDirectory
- the current directoryfile
- the file to be returned as absolute filecurrentDirectory
as basis for relative pathsFile.isAbsolute()
,
Arg.isVariable(String)
,
File.getAbsoluteFile()
public static List<String> getPathElements(File file)
file
. The absolute path of
the file is used to evaluate the path elements.
For instance, a list with the 3 elements "var", "tmp", "out.txt" is returned for an input file "/var/tmp/out.txt".
file
- the file whose path elements should be returnedfile
public static List<File> expandFiles(String... paths)
files
list contains no wildcard, the
files are simply returned; all wildcard files are expanded.paths
- the file paths, possibly containing wildcard partspublic static List<File> expandFiles(File currentDirectory, String... paths)
files
list contains no wildcard, the
files are simply returned; all wildcard files are expanded. The given
current directory serves as basis for all relative paths.currentDirectory
- the basis for all relative pathspaths
- the file paths, possibly containing wildcard partspublic static FilenameFilter getFileNameFilter(String name)
The wildcards "*" and "?" are supported. "*" stands for any character repeated 0 to many times, "?" for exactly one arbitrary character. Both characters can be escaped with a preceding backslash character \ (Unix and MAC) or % character (Windows).
name
- the name or pattern without pathpublic static boolean isWildcardFileName(String name)
name
- the name or pathpublic static File getOutputDirectoryGivenClass(Class<?> clazz)
clazz
- public static File getDirectoryOfClassFile(Class<?> clazz)
clazz
- public static File getDirectoryOfClassFile(String className)
className
- fully qualified class nameCopyright © 2024. All rights reserved.