FileUtil
@Deprecated public final class FileUtil extends Object
Modifier and Type | Method and Description |
---|---|
static File |
createDateDirs(File parentDir)
Deprecated.
Creates (if not already existing) a series of directories reflecting
the current date, up to the day unit, under a given parent directory.
|
static File |
createDateDirs(File parentDir,
Date date)
Deprecated.
Creates (if not already existing) a series of directories reflecting
a date, up to the day unit, under a given parent directory.
|
static File |
createDateTimeDirs(File parentDir)
Deprecated.
Creates (if not already existing) a series of directories reflecting
the current date and time, up to the seconds, under a given parent
directory.
|
static File |
createDateTimeDirs(File parentDir,
Date dateTime)
Deprecated.
Creates (if not already existing) a series of directories reflecting
a date and time, up to the seconds, under a given parent directory.
|
static File |
createDirsForFile(File file)
Deprecated.
Create all parent directories for a file if they do not exists.
|
static int |
deleteEmptyDirs(File parentDir)
Deprecated.
Deletes all directories that are empty from a given parent directory.
|
static int |
deleteEmptyDirs(File parentDir,
Date date)
Deprecated.
Deletes all directories that are empty and are older
than the given date.
|
static void |
deleteFile(File file)
Deprecated.
Deletes a file or a directory recursively.
|
static String |
fromSafeFileName(String safeFileName)
Deprecated.
Converts a "safe" file name originally created with
toSafeFileName(String) into its original string. |
static String[] |
head(File file,
int numberOfLinesToRead)
Deprecated.
Returns the specified number of lines starting from the beginning
of a text file.
|
static String[] |
head(File file,
String encoding,
int numberOfLinesToRead)
Deprecated.
Returns the specified number of lines starting from the beginning
of a text file, using the given encoding.
|
static String[] |
head(File file,
String encoding,
int numberOfLinesToRead,
boolean stripBlankLines)
Deprecated.
Returns the specified number of lines starting from the beginning
of a text file, using the given encoding.
|
static String[] |
head(File file,
String encoding,
int numberOfLinesToRead,
boolean stripBlankLines,
IInputStreamFilter filter)
Deprecated.
Returns the specified number of lines starting from the beginning
of a text file, using the given encoding.
|
static void |
moveFile(File sourceFile,
File targetFile)
Deprecated.
Moves a file to a new file location.
|
static void |
moveFileToDir(File sourceFile,
File targetDir)
Deprecated.
Moves a file to a directory.
|
static String[] |
tail(File file,
int numberOfLinesToRead)
Deprecated.
Returns the specified number of lines starting from the end
of a text file.
|
static String[] |
tail(File file,
String encoding,
int numberOfLinesToRead)
Deprecated.
Returns the specified number of lines starting from the end
of a text file.
|
static String[] |
tail(File file,
String encoding,
int numberOfLinesToRead,
boolean stripBlankLines)
Deprecated.
Returns the specified number of lines starting from the end
of a text file.
|
static String[] |
tail(File file,
String encoding,
int numberOfLinesToRead,
boolean stripBlankLines,
IInputStreamFilter filter)
Deprecated.
Returns the specified number of lines starting from the end
of a text file.
|
static String |
toSafeFileName(String unsafeFileName)
Deprecated.
Converts any String to a valid file-system file name representation.
|
static void |
visitAllDirs(File dir,
IFileVisitor visitor)
Deprecated.
Visits only directories under a directory.
|
static void |
visitAllDirs(File dir,
IFileVisitor visitor,
FileFilter filter)
Deprecated.
Visits only directories under a directory.
|
static void |
visitAllDirsAndFiles(File dir,
IFileVisitor visitor)
Deprecated.
Visits all files and directories under a directory.
|
static void |
visitAllDirsAndFiles(File dir,
IFileVisitor visitor,
FileFilter filter)
Deprecated.
Visits all files and directories under a directory.
|
static void |
visitAllFiles(File dir,
IFileVisitor visitor)
Deprecated.
Visits all files (and only files) under a directory, including
sub-directories.
|
static void |
visitAllFiles(File dir,
IFileVisitor visitor,
FileFilter filter)
Deprecated.
Visits all files (and only files) under a directory, including
sub-directories.
|
static void |
visitEmptyDirs(File dir,
IFileVisitor visitor)
Deprecated.
Visits only empty directories under a directory.
|
static void |
visitEmptyDirs(File dir,
IFileVisitor visitor,
FileFilter filter)
Deprecated.
Visits only empty directories under a directory.
|
public static String toSafeFileName(String unsafeFileName)
fromSafeFileName(String)
to get back the original name.unsafeFileName
- the file name to make safe.public static String fromSafeFileName(String safeFileName)
toSafeFileName(String)
into its original string.safeFileName
- the file name to convert to its origianl formpublic static void moveFileToDir(File sourceFile, File targetDir) throws IOException
moveFile(File, File)
:
sourceFile
- source file to movetargetDir
- target destinationIOException
- cannot move file.public static void moveFile(File sourceFile, File targetFile) throws IOException
File.renameTo(File)
method in such that:
sourceFile
- source file to movetargetFile
- target destinationIOException
- cannot move file.public static void deleteFile(File file) throws IOException
null
or does not exist, nothing happens.
file
- file or directory to deleteIOException
- cannot delete file.public static int deleteEmptyDirs(File parentDir)
parentDir
- the directory where to start looking for empty
directoriespublic static int deleteEmptyDirs(File parentDir, Date date)
null
, all empty
directories will be deleted, regardless of their date.parentDir
- the directory where to start looking for empty
directoriesdate
- the date to compare empty directories againstpublic static File createDirsForFile(File file) throws IOException
file
- the file to create parent directories forIOException
- if somethign went wrong creating the parent
directoriespublic static void visitAllDirsAndFiles(File dir, IFileVisitor visitor)
dir
- the directoryvisitor
- the visitorpublic static void visitAllDirsAndFiles(File dir, IFileVisitor visitor, FileFilter filter)
dir
- the directoryvisitor
- the visitorfilter
- an optional filter to restrict the files being visitedpublic static void visitEmptyDirs(File dir, IFileVisitor visitor)
dir
- the directoryvisitor
- the visitorpublic static void visitEmptyDirs(File dir, IFileVisitor visitor, FileFilter filter)
dir
- the directoryvisitor
- the visitorfilter
- an optional filter to restrict the visited directoriespublic static void visitAllDirs(File dir, IFileVisitor visitor)
dir
- the directoryvisitor
- the visitorpublic static void visitAllDirs(File dir, IFileVisitor visitor, FileFilter filter)
dir
- the directoryvisitor
- the visitorfilter
- an optional filter to restrict the visited directoriespublic static void visitAllFiles(File dir, IFileVisitor visitor)
dir
- the directoryvisitor
- the visitorpublic static void visitAllFiles(File dir, IFileVisitor visitor, FileFilter filter)
dir
- the directoryvisitor
- the visitorfilter
- an optional filter to restrict the files being visitedpublic static String[] head(File file, int numberOfLinesToRead) throws IOException
file
- the file to read lines fromnumberOfLinesToRead
- the number of lines to readIOException
- i/o problempublic static String[] head(File file, String encoding, int numberOfLinesToRead) throws IOException
file
- the file to read lines fromencoding
- the file encodingnumberOfLinesToRead
- the number of lines to readIOException
- i/o problempublic static String[] head(File file, String encoding, int numberOfLinesToRead, boolean stripBlankLines) throws IOException
file
- the file to read lines fromencoding
- the file encodingnumberOfLinesToRead
- the number of lines to readstripBlankLines
- whether to return blank lines or notIOException
- i/o problempublic static String[] head(File file, String encoding, int numberOfLinesToRead, boolean stripBlankLines, IInputStreamFilter filter) throws IOException
file
- the file to read lines fromencoding
- the file encodingnumberOfLinesToRead
- the number of lines to readstripBlankLines
- whether to return blank lines or notfilter
- InputStream filterIOException
- i/o problempublic static String[] tail(File file, int numberOfLinesToRead) throws IOException
file
- the file to read lines fromnumberOfLinesToRead
- the number of lines to readIOException
- i/o problempublic static String[] tail(File file, String encoding, int numberOfLinesToRead) throws IOException
file
- the file to read lines fromencoding
- the file encodingnumberOfLinesToRead
- the number of lines to readIOException
- i/o problempublic static String[] tail(File file, String encoding, int numberOfLinesToRead, boolean stripBlankLines) throws IOException
file
- the file to read lines fromencoding
- the file encodingnumberOfLinesToRead
- the number of lines to readstripBlankLines
- whether to return blank lines or notIOException
- i/o problempublic static String[] tail(File file, String encoding, int numberOfLinesToRead, boolean stripBlankLines, IInputStreamFilter filter) throws IOException
file
- the file to read lines fromencoding
- the file encodingnumberOfLinesToRead
- the number of lines to readstripBlankLines
- whether to return blank lines or notfilter
- InputStream filterIOException
- i/o problempublic static File createDateDirs(File parentDir) throws IOException
/<parentDir>/2000/12/31/
parentDir
- the parent directory where to create date directoriesIOException
- if the parent directory is not validpublic static File createDateDirs(File parentDir, Date date) throws IOException
/<parentDir>/2000/12/31/
parentDir
- the parent directory where to create date directoriesdate
- the date to create directories fromIOException
- if the parent directory is not validpublic static File createDateTimeDirs(File parentDir) throws IOException
/<parentDir>/2000/12/31/13/34/12/
parentDir
- the parent directory where to create date directoriesIOException
- if the parent directory is not validpublic static File createDateTimeDirs(File parentDir, Date dateTime) throws IOException
/<parentDir>/2000/12/31/13/34/12/
parentDir
- the parent directory where to create date directoriesdateTime
- the date to create directories fromIOException
- if the parent directory is not validCopyright © 2008–2016 Norconex Inc.. All rights reserved.