Class IO
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMaximum filename size used in JEB (255 allowed for Linux, 259 for Windows file)static final intMaximum foldername size used in JEB (248 for Windows folder) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringProvide an absolute simplified path.static StringProvide an absolute simplified path.static voidaddFileToJar(JarOutputStream jar, File file, String entryName) Add a new entry to a a jar output stream.static voidaddFileToZip(ZipOutputStream zip, File file, String entryName) Add a new entry to a a zip output stream.static StringReturn the base name of the provided path.static booleancheckFileFreshness(File file, long millis, boolean cleanStaleFile) static booleancompareFiles(File file0, File file1) Compare the contents of two files for equality.static booleancompressFolder(String folderPath, String zipfilePath) Compress a folder and its contents to a zip archive.static longcopy(InputStream input, OutputStream output) A wrapper aroundcopyStream(InputStream, OutputStream).static ThreadcopyAsync(InputStream input, OutputStream output) Copy a continuous stream of data from a source to a destination.static voidCopy a source file to a destination.static longcopyStream(InputStream input, OutputStream output) Read bytes from an input stream and dump them to an output stream.static longcopyStream(InputStream input, OutputStream output, byte[] buffer) Read bytes from an input stream and dump them to an output stream.static booleanSafely create a directory.static booleancreateDirectory(String path) Safely create a directory.static booleancreateFile(File file, boolean createDirs) Create an empty file.static FilecreateFolder(String path) Create or retrieve a directory.static voidcreateFoldersForFile(File file) Create the directory structure needed to store a file.static FileCreate an empty file in the safe temporary area.static FileCreate an empty file in the temporary folder.static FilecreateTempFile(String exactname) Create a file (with an exact name) in the default temp folder.static FilecreateTempFile(String basename, String extension) Create a file in the default temp folder.static FilecreateTempFileNumbered(String name) Create a new file with the provided name in the default temp folder.static FilecreateTempFolder(String folderName) Create a directory in the default temporary-file directory.static booleandeleteDirectory(File dir) Delete a directory and its contents recursively.static booleandeleteDirectory(String path) Delete a directory and its contents recursively.static booleanDelete a directory contents recursively (ie, clear the directory).static voidDelete a folder and all its contents recursively, when the virtual machine terminates.static booleandeleteFile(File file) Delete a file.static StringReturn the directory name of the provided path.static StringescapeFileName(String filename) Escape filename invalid characters with an underscore.static StringescapeFileName(String filename, char newChar) Escape illegal characters in filename by the provided char.static StringescapeFileNameStrict(String filename) Create a valid filename with an underscore for non alphanumeric char, '-', '_', '.' nor '''.static StringescapeFileNameStrict(String filename, char newChar) Create a valid filename from any string.static StringexpandPath(String path) Perform expansion of certain shell artifacts used in path names.static voidextractToFolder(File inputZipFile, File outputFolder) Extract the contents of a zip archive to a target folder.static StringgetCwd()Get the path of the current working directory.static StringgetExtension(File file) Extract the extension of a file path.static StringgetExtension(String path) Extract the extension of a file path.static bytegetFirstByte(String path) Get the first byte of a file.static intgetFirstIntLE(String path) Get the first 4-byte of a file, read as a little-endian integer.static shortgetFirstShortLE(String path) Get the first 2-byte of a file, read as a little-endian short.static FileRetrieve the current user's home folder.static StringGet original working directory, i.e.static FilegetParentFile2(File file) A safer implementation ofFile.getParentFile().static StringgetRelativePath(File file, File base) Provide the path to a file relative to a base.static FileRetrieve the JEB session-specific temporary folder.static FileRetrieve the temporary folder.static booleanDetermine if a hypothetical file would be contained within a hypothetical folder, i.e.static booleanDetermine if a path refers to an existing file.static booleanDetermine whether the provided input string looks like a URL.Recursively do a directory listing.Recursively do a directory listing.static FilenoExtension(File file) static StringnoExtension(String path) Parse the elements of a path.static byte[]Read the contents of a binary file that is at most 2 Gb.static byte[]Read the contents of a binary file that is at most 2 Gb.static byte[]Read the contents of a binary file.static byte[]readFileSafe(File file) Read a binary file safely.static StringRead a line from the standard input.static StringRead a line from the standard input.static byte[]Read and reliably return all bytes of an input stream.Read the UTF-8 encoded lines of a text file.Read the lines of a text file.readLines(InputStream input) Read the contents of a stream as a text buffer of UTF-8 encoded strings.readLines(InputStream input, Charset encoding) Read the contents of a stream as a line of strings.readLinesSafe(File file) Read the lines of a UTF8 encoded text file.readLinesSafe(File file, Charset encoding) Read the lines of a text file.static booleanrenameFile(File src, File dst, int mode) Rename a file with options.static FilereplaceExtension(File file, String extension) static String[]A safe version ofFile.list().static String[]safeList(File f, FilenameFilter filter) A safe version ofFile.list(FilenameFilter).static File[]A safe version ofFile.listFiles().static File[]safeListFiles(File f, FileFilter filter) A safe version ofFile.listFiles(FileFilter).static StringsanitizePath(String path, boolean isSinglePathElement, boolean replaceBlankCharacters) Sanitize a path.static StringsanitizePathUnsafe(String path) Attempt to sanitize a path.static StringSet the path of the current working directory.static StringsimplifyPath(String path) Simplify a path.static StringsimplifyPathUnix(String path) SeesimplifyPath(String).static StringsimplifyPathWindows(String path) SeesimplifyPath(String).static String[]splitExtension(String path) Split a file path into its extension-less part and its extension.static String[]Split a path into its base part and its filename part.static voidWrite data to a file.static voidWrite data to a file whose containing directory structure may not exist.static voidWrite data to a file.static voidWrite data to a file whose containing directory structure may not exist.static voidWrite a string to a file using the default character encoding of the current system.static voidWrite a string to a file using the given character encoding of the current system.static booleanwriteFileSafe(File file, byte[] data, boolean createDirs) Write a binary file safely.static booleanwriteFileSafe(File file, byte[] data, int offset, int size, boolean createDirs) Write a binary file safely.static voidwriteLines(File file, List<? extends CharSequence> lines) Write UTF-8 encoded strings.static voidwriteLines(File file, List<? extends CharSequence> lines, Charset encoding) Write strings.static voidwriteLines(OutputStream output, List<? extends CharSequence> lines) Write UTF-8 encoded strings.static voidwriteLines(OutputStream output, List<? extends CharSequence> lines, Charset encoding) Write strings.static booleanwriteLinesSafe(File file, List<? extends CharSequence> lines) Write UTF-8 encoded strings.static booleanwriteLinesSafe(File file, List<? extends CharSequence> lines, Charset encoding) Write strings.static booleanwriteLinesSafe(OutputStream output, List<? extends CharSequence> lines) Write UTF-8 encoded strings.static booleanwriteLinesSafe(OutputStream output, List<? extends CharSequence> lines, Charset encoding) Write strings.
-
Field Details
-
MAX_FILENAME_SIZE
public static final int MAX_FILENAME_SIZEMaximum filename size used in JEB (255 allowed for Linux, 259 for Windows file)- See Also:
-
MAX_PATH_SIZE
public static final int MAX_PATH_SIZEMaximum foldername size used in JEB (248 for Windows folder)- See Also:
-
-
Constructor Details
-
IO
public IO()
-
-
Method Details
-
setCwd
Set the path of the current working directory.Note: handle with care, changing the CWD may not impact all subsequent file read and write operations. It is safer to retrieve and use the CWD with
getCwd().- Parameters:
cwd-- Returns:
- previous working directory
-
getCwd
Get the path of the current working directory.- Returns:
-
getOriginalCwd
Get original working directory, i.e. the value of the current directory set by the JVM when the program was started.This method is unreliable. It assumes that all updates to the current directory are done through
this class.- Returns:
-
isFile
Determine if a path refers to an existing file.- Parameters:
path-- Returns:
-
createFolder
Create or retrieve a directory.- Parameters:
path- directory path- Returns:
- the directory file object
- Throws:
IOException- on creation error
-
createDirectory
Safely create a directory.- Parameters:
path-- Returns:
- true on success, else false
-
createDirectory
Safely create a directory.- Parameters:
f-- Returns:
-
deleteDirectory
Delete a directory and its contents recursively.- Parameters:
path-- Returns:
- true on success
-
deleteDirectory
Delete a directory and its contents recursively.- Parameters:
dir-- Returns:
- true on success, false if errors were encountered; note that some files and directories may have been deleted
-
deleteDirectoryContents
Delete a directory contents recursively (ie, clear the directory). The directory itself is not deleted.- Parameters:
dir-- Returns:
- true on success, false if errors were encountered; note that some files and directories may have been deleted
-
deleteFile
Delete a file.- Parameters:
file- the file to be deleted- Returns:
- true on success
-
renameFile
Rename a file with options.- Parameters:
src- source filedst- destinationmode- define the mechanics of the renaming operations:- 0: standard rename, fail if 'dst' already exists or 'src' does not exist
- 1: overwrite 'dst' if 'dst' already exists
- 2: delete 'src' if 'dst' already exists
- Returns:
- true on success
-
listFiles
Recursively do a directory listing. The list returned is a list of true files (not directories). Refer to theDirectoryEnumeratorobject for a more powerful file enumerator.- Parameters:
folderpath-- Returns:
- the list of absolute file paths
-
listFiles
Recursively do a directory listing. The list returned is a list of true files (not directories). Refer to theDirectoryEnumeratorobject for a more powerful file enumerator.- Parameters:
folder-- Returns:
- the list of absolute files
-
safeList
A safe version ofFile.list().- Parameters:
f- a non-null file object- Returns:
- non null array
-
safeList
A safe version ofFile.list(FilenameFilter).- Parameters:
f- a non-null file objectfilter- a file filter- Returns:
- non-null array
-
safeListFiles
A safe version ofFile.listFiles().- Parameters:
f- a non-null file object- Returns:
- non null array
-
safeListFiles
A safe version ofFile.listFiles(FileFilter).- Parameters:
f- a non-null file objectfilter- a file filter- Returns:
- non-null array
-
inFolder
Determine if a hypothetical file would be contained within a hypothetical folder, i.e. whether or not the folder would be an ancestor of the file.- Parameters:
file- file or folder to test (whose existence is not required)folder- candidate ancestor folder (whose existence is not required)- Returns:
- true if the candidate folder looks like an ancestor folder of the file
-
getHomeFolder
Retrieve the current user's home folder.- Returns:
-
getTempFolder
Retrieve the temporary folder.- Returns:
- the temp folder, never null
-
getSessionTemporaryFolder
Retrieve the JEB session-specific temporary folder. That folder is unique per session, and can be used to drop additional temporary files and folders. Its contents is deleted when the session ends (i.e. when the owning JEB instance is terminated).- Returns:
- this JEB session's temporary folder
-
createTempFolder
Create a directory in the default temporary-file directory.- Parameters:
folderName- optional folder name; if null, a randomly named folder will be created- Returns:
- a File representing the newly created directory, or null on error
- Throws:
IOException- if an IO exception happened
-
createTempFile
Create an empty file in the temporary folder.- Returns:
- the file
- Throws:
IOException- on file creation error
-
createSafeTempFile
Create an empty file in the safe temporary area.- Returns:
- the file
- Throws:
IOException- on file creation error
-
createTempFile
Create a file in the default temp folder.- Parameters:
basename- optional base nameextension- optional extension (suffix)- Returns:
- Throws:
IOException
-
createTempFile
Create a file (with an exact name) in the default temp folder.- Parameters:
exactname- exact file name- Returns:
- the file object (the file itself may or may not exist when the method returns)
-
createTempFileNumbered
Create a new file with the provided name in the default temp folder. If a file with the provided name already exists, counter-suffixed names are tried (NAME.1,NAME.2, etc.) until the first non-existent entry is found.- Parameters:
name- desired file name- Returns:
- the file object (the file itself does not exist at the time this method returns)
- Throws:
IOException
-
createFile
Create an empty file.- Parameters:
file-createDirs- if true, the directory structure needed to contain the file will also be created- Returns:
- true if the named file does not exist and was successfully created; false if the named file already exists
- Throws:
IOException
-
createFoldersForFile
Create the directory structure needed to store a file.- Parameters:
file- a file- Throws:
IOException
-
deleteDirectoryOnExit
Delete a folder and all its contents recursively, when the virtual machine terminates.- Parameters:
dir- folder to be deleted
-
copyFile
Copy a source file to a destination. The copy process is interruptible.- Parameters:
src- source file (not a directory)dst- destination file or directoryoverwrite- if true, the destination file may be overwritten if it already exists- Throws:
FileNotFoundException- the source is not foundFileAlreadyExistsException- the destination would be overwrittenIOException- other IO exception
-
copyStream
public static long copyStream(InputStream input, OutputStream output, byte[] buffer) throws IOException Read bytes from an input stream and dump them to an output stream. The copy process is interruptible.- Parameters:
input-output-buffer- recommended use: multiple of 0x1000- Returns:
- Throws:
IOException
-
copyStream
Read bytes from an input stream and dump them to an output stream. The copy process is interruptible.- Parameters:
input-output-- Returns:
- Throws:
IOException
-
copy
A wrapper aroundcopyStream(InputStream, OutputStream). Read bytes from an input stream and dump them to an output stream. The copy process is interruptible.- Parameters:
input-output-- Returns:
- Throws:
IOException
-
writeFile
public static void writeFile(File file, byte[] data, int offset, int size, boolean createDirs) throws IOException Write data to a file whose containing directory structure may not exist. Existing file contents will be overwritten.- Parameters:
file-data-offset-size-createDirs- create the intermediate directories if need be- Throws:
IOException
-
writeFile
Write data to a file whose containing directory structure may not exist. Existing file contents will be overwritten.- Parameters:
file-data-createDirs-- Throws:
IOException
-
writeFile
Write data to a file. Existing file contents will be overwritten.- Parameters:
file-data-offset-size-- Throws:
IOException
-
writeFile
Write data to a file. Existing file contents will be overwritten.- Parameters:
file- destination filedata- binary data to write- Throws:
IOException- on error
-
writeFile
Write a string to a file using the default character encoding of the current system. Existing file contents will be overwritten.- Parameters:
file- destination filestr- string- Throws:
IOException- on error
-
writeFile
Write a string to a file using the given character encoding of the current system. Existing file contents will be overwritten.- Parameters:
file-str-charsetName-- Throws:
IOException
-
readFile
Read the contents of a binary file that is at most 2 Gb.- Parameters:
file- file to readmaxAllowedSize- optional maximum size, -1 means the max (2 Gb)- Returns:
- the contents of the file
- Throws:
IOException- on IO error, or if the read size exceeds the limit
-
readFile
Read the contents of a binary file that is at most 2 Gb.- Parameters:
file- file to read- Returns:
- the contents of the file
- Throws:
IOException- on IO error, or if the read size exceeds 2 Gb
-
readFile
Read the contents of a binary file.- Parameters:
path-- Returns:
- Throws:
IOException
-
readInputStream
Read and reliably return all bytes of an input stream. The stream must be less than 2Gb. The caller is responsible for closing the input stream after reading.- Parameters:
in-- Returns:
- Throws:
IOException
-
readLines
Read the contents of a stream as a line of strings.- Parameters:
input- the input streamencoding- the stream encoding- Returns:
- a list of strings, without new-line characters
- Throws:
IOException- on IO error
-
readLines
Read the contents of a stream as a text buffer of UTF-8 encoded strings.- Parameters:
input-- Returns:
- Throws:
IOException
-
readLines
Read the lines of a text file.- Parameters:
file-encoding-- Returns:
- Throws:
IOException
-
readLines
Read the UTF-8 encoded lines of a text file.- Parameters:
file- input file- Returns:
- a list of strings, without new-line characters
- Throws:
IOException- on IO error
-
readLinesSafe
Read the lines of a text file. On error, the method returns null.- Parameters:
file- input fileencoding- file encoding- Returns:
- a list of lines without newline chars, null on error
-
readLinesSafe
Read the lines of a UTF8 encoded text file. On error, the method returns null.- Parameters:
file-- Returns:
- a list of lines without newline chars, null on error
-
writeLines
public static void writeLines(OutputStream output, List<? extends CharSequence> lines, Charset encoding) throws IOException Write strings.- Parameters:
output-lines-encoding-- Throws:
IOException
-
writeLines
public static void writeLines(OutputStream output, List<? extends CharSequence> lines) throws IOException Write UTF-8 encoded strings.- Parameters:
output-lines-- Throws:
IOException
-
writeLines
public static void writeLines(File file, List<? extends CharSequence> lines, Charset encoding) throws IOException Write strings.- Parameters:
file-lines-encoding-- Throws:
IOException
-
writeLines
Write UTF-8 encoded strings.- Parameters:
file-lines-- Throws:
IOException
-
writeLinesSafe
public static boolean writeLinesSafe(OutputStream output, List<? extends CharSequence> lines, Charset encoding) Write strings. On error, the method returns false.- Parameters:
output-lines-
-
writeLinesSafe
Write UTF-8 encoded strings. On error, the method returns false.- Parameters:
output-lines-- Returns:
-
writeLinesSafe
public static boolean writeLinesSafe(File file, List<? extends CharSequence> lines, Charset encoding) Write strings. On error, the method returns false.- Parameters:
file-lines-encoding-- Returns:
-
writeLinesSafe
Write UTF-8 encoded strings. On error, the method returns false.- Parameters:
file-lines-- Returns:
-
getFirstIntLE
Get the first 4-byte of a file, read as a little-endian integer. This method never throws exceptions. If an error occurs, 0 is returned. It is up to the client to handle that special case.- Parameters:
path- file path- Returns:
- the first int, 0 on error
-
getFirstShortLE
Get the first 2-byte of a file, read as a little-endian short. This method never throws exceptions. If an error occurs, 0 is returned. It is up to the client to handle that special case.- Parameters:
path-- Returns:
-
getFirstByte
Get the first byte of a file. This method never throws exceptions. If an error occurs, 0 is returned. It is up to the client to handle that special case.- Parameters:
path-- Returns:
-
compressFolder
Compress a folder and its contents to a zip archive.- Parameters:
folderPath- input folderzipfilePath- output zip file path- Returns:
- true on success
-
extractToFolder
Extract the contents of a zip archive to a target folder.- Parameters:
inputZipFile- input zip file pathoutputFolder- output folder directory- Throws:
IOException- if an error occurred; the current state of extraction within the target folder is not erased
-
addFileToZip
public static void addFileToZip(ZipOutputStream zip, File file, String entryName) throws IOException Add a new entry to a a zip output stream.- Parameters:
zip-file-entryName-- Throws:
IOException
-
addFileToJar
public static void addFileToJar(JarOutputStream jar, File file, String entryName) throws IOException Add a new entry to a a jar output stream.- Parameters:
jar-file-entryName-- Throws:
IOException
-
readFileSafe
Read a binary file safely. If any error happens, an empty array is returned.- Parameters:
file- input file- Returns:
- the bytes in the file, never null (empty array on error)
-
writeFileSafe
public static boolean writeFileSafe(File file, byte[] data, int offset, int size, boolean createDirs) Write a binary file safely.- Parameters:
file-data-createDirs-- Returns:
-
writeFileSafe
Write a binary file safely.- Parameters:
file-data-createDirs-- Returns:
-
readInputLineSafe
Read a line from the standard input. This method is safe to use; it does not raise, instead returning a null string on error.- Returns:
-
readInputLine
Read a line from the standard input.- Returns:
- Throws:
IOException
-
getParentFile2
A safer implementation ofFile.getParentFile(). If the input file is a single-level relative path (eg, "abc"), this method will first retrieve the absolute path (relative to the current folder) before trying to retrieve the parent folder.- Parameters:
file- file or folder- Returns:
- null if there is no parent folder, eg in the case of a a root folder
-
expandPath
Perform expansion of certain shell artifacts used in path names.Currently, the expansions performed are:
- a leading tilda is expanded to a user's home directory
- Parameters:
path-- Returns:
- a full path name, if possible - otherwise, the original path is returned
-
copyAsync
Copy a continuous stream of data from a source to a destination. This method is non-blocking.- Parameters:
input- the source input streamoutput- the destination output stream- Returns:
- the daemon worker thread in charge of copying the data
-
dirname
Return the directory name of the provided path. The returned string may be empty. It will is not terminated by slash or backslash.- Parameters:
path- a path- Returns:
- never null
-
basename
Return the base name of the provided path. The base name is the part of the path that follows the last file separator character (slash or backslash). No further processing is done. The returned string may be empty or blank. It does not contain slash or backslash.- Parameters:
path- a path- Returns:
- never null
-
parsePathElements
Parse the elements of a path.- Parameters:
s- a path- Returns:
- a list of path elements, possibly empty
-
escapeFileName
Escape filename invalid characters with an underscore.For proper path sanitization, use
sanitizePath(String, boolean, boolean).- Parameters:
filename- to escape- Returns:
- the escaped filename
-
escapeFileName
Escape illegal characters in filename by the provided char. Note than this is a black-list escaper (whitelist character would be too costly to manage any char) so file name can still be irrelevant on the target Operating System. The list of excluded characters are ':', '\', '/', '*', '"', '?', '|', '<', '>' which covers most of the invalid characters.For proper path sanitization, use
sanitizePath(String, boolean, boolean).- Parameters:
filename- to escapenewChar- replacement character- Returns:
- the escaped filename
-
escapeFileNameStrict
Create a valid filename with an underscore for non alphanumeric char, '-', '_', '.' nor '''.For proper path sanitization, use
sanitizePath(String, boolean, boolean).- Parameters:
filename- to escape- Returns:
- the escaped filename
-
escapeFileNameStrict
Create a valid filename from any string. Compared toescapeFileName(String, char), this is a white-list escaper so generated filename will be legal on any non-exotic target Operating System. The list of allowed characters are any alphanumeric char, '-', '_', '.', '''.For proper path sanitization, use
sanitizePath(String, boolean, boolean).- Parameters:
filename- to escapenewChar- replacement character- Returns:
- the escaped filename
-
sanitizePathUnsafe
Attempt to sanitize a path.Under some conditions, the returned path may be unsafe, eg on Windows: the sanitization of a path like "x::z" will generate an unsafe path. You must use
sanitizePath(String, boolean, boolean)to guarantee sanitization.- Parameters:
path-- Returns:
-
sanitizePath
public static String sanitizePath(String path, boolean isSinglePathElement, boolean replaceBlankCharacters) Sanitize a path. The returned path is guaranteed to be legal on the current filesystem (FS) if and only if the element being sanitized is a single path element. For full paths elements, sanitization cannot be guaranteed because some characters which could yield to bad paths, cannot be safely sanitized.Notes:
- the following characters are always sanitized:? % * | < > "
- if a single path element is provided, the following characters are sanitized as well:/ \ :- Parameters:
path- a path (absolute or not)isSinglePathElement- true if the provided path should be treated as a single path element, allowing more aggressive replacementsreplaceBlankCharacters- if true, sanitize all blank characters (per the Unicode definition of a blank character) as well, even though some may be legal- Returns:
- a sanitized path, never null, guaranteed to be valid on the current FS
-
getRelativePath
Provide the path to a file relative to a base.- Parameters:
file- a filebase- the base to check for- Returns:
- null if `file` is not rooted in `base`; else, the relative path of `file` (relative to `base`)
-
compareFiles
Compare the contents of two files for equality.- Parameters:
file0- first filefile1- second file- Throws:
FileNotFoundException- one of the input file is not foundIOException- other IO exception
-
splitPath
Split a path into its base part and its filename part.Unlike
File.getName(), this method considers both slash and backslash to be valid path separators.- Parameters:
path-- Returns:
- a two-element array: the first element contains the base and may be empty (if non-empty, it will always end by a separator); the second element is the name, which does not contain any separator
-
splitExtension
Split a file path into its extension-less part and its extension.- Parameters:
path- a file path- Returns:
- a 2-element string array; the extension, if any, is the second element and always start with '.' unless it's empty
-
getExtension
Extract the extension of a file path.- Parameters:
path- a path- Returns:
- the extension (always starting with a dot), or the empty string
-
getExtension
Extract the extension of a file path.- Parameters:
file- a file- Returns:
- the extension (always starting with a dot), or the empty string
-
noExtension
- Parameters:
path-- Returns:
-
noExtension
- Parameters:
file-- Returns:
-
replaceExtension
- Parameters:
file-extension- the new extension, eg ".xyz"- Returns:
-
isUrl
Determine whether the provided input string looks like a URL.- Parameters:
s-- Returns:
-
abs
Provide an absolute simplified path. This method is OS-dependent.Rules:
-.and..uses are resolved.
- Multiple-path separator uses such as///or\\are resolved.
- Redundant trailing separators are removed.
- The empty path is always resolved to..
- If the FS is case-insensitive (e.g. NTFS), the case is not standardized (Windows).
- Symbolic links are not resolved.- Parameters:
file- input file- Returns:
- absolute simplified path
-
abs
Provide an absolute simplified path. This method is OS-dependent.Rules:
-.and..uses are resolved.
- Multiple-path separator uses such as///or\\are resolved.
- Redundant trailing separators are removed.
- The empty path is always resolved to..
- If the FS is case-insensitive (e.g. NTFS), the case is not standardized (Windows).
- Symbolic links are not resolved.- Parameters:
path- input path- Returns:
- absolute simplified path
-
simplifyPath
Simplify a path. This method is OS-dependent. To call a specific (Unix or Windows) version of this method, usesimplifyPathUnix(String)orsimplifyPathWindows(String).Rules:
-.and..uses are resolved.
- Multiple-path separator uses such as///or\\are resolved.
- Redundant trailing separators are removed.
- The empty path is always resolved to..
- If the FS is case-insensitive (e.g. NTFS), the case is not standardized (Windows).
- Symbolic links are not resolved.- Parameters:
path- input path- Returns:
- absolute simplified path
-
simplifyPathUnix
SeesimplifyPath(String). -
simplifyPathWindows
SeesimplifyPath(String). -
checkFileFreshness
- Parameters:
file-millis-cleanStaleFile-- Returns:
- true if the file exists and its last modification timestamp is less than
millisms old
-