|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.alee.utils.FileUtils
public final class FileUtils
This class provides a set of utilities to work with files, file names and their extensions.
Note that methods which request information about files from the system has their own caches to improve performance. If you will need to clear that cache simply call the corresponding clearCache method, for example: For method "isHidden" you will need to call "clearIsHiddenCache" and all cached values will be resetted.
Field Summary | |
---|---|
static long |
GB
Number of bytes in 1 gigabyte. |
static long |
KB
Number of bytes in 1 kilobyte. |
static long |
MB
Number of bytes in 1 megabyte. |
static long |
PB
Number of bytes in 1 petabyte. |
Constructor Summary | |
---|---|
FileUtils()
|
Method Summary | |
---|---|
static java.lang.String |
canonicalPath(java.io.File file)
Returns file canonical path if its possible or absolute path otherwise. |
static void |
clearDirectory(java.io.File dir)
Deletes all child files and directories for specified directory. |
static void |
clearDisplayFileCreationDateCache()
Clears cache for "getDisplayFileCreationDate" method. |
static void |
clearDisplayFileCreationDateCache(java.lang.String absolutePath)
Clears cache for "getDisplayFileCreationDate" method for specified file path. |
static void |
clearDisplayFileModificationDateCache()
Clears cache for "getDisplayFileModificationDate" method. |
static void |
clearDisplayFileModificationDateCache(java.lang.String absolutePath)
Clears cache for "getDisplayFileModificationDate" method for specified file path. |
static void |
clearDisplayFileNameCache()
Clears cache for "getDisplayFileName" method. |
static void |
clearDisplayFileNameCache(java.lang.String absolutePath)
Clears cache for "getDisplayFileName" method for specified file path. |
static void |
clearFileCaches(java.io.File file)
Clears all caches for specified file. |
static void |
clearFileCaches(java.lang.String path)
Clears all caches for file under the specified path. |
static void |
clearFileDescriptionCache()
Clears cache for "getFileDescription" method. |
static void |
clearFileDescriptionCache(java.lang.String absolutePath)
Clears cache for "getFileDescription" method for specified file path. |
static void |
clearFilesCaches(java.io.File... files)
Clears all caches for specified files. |
static void |
clearFileTypeDescriptionCache()
Clears cache for "getFileTypeDescription" method. |
static void |
clearFileTypeDescriptionCache(java.lang.String absolutePath)
Clears cache for "getFileTypeDescription" method for specified file path. |
static void |
clearIsCdDriveCache()
Clears cache for "isCdDrive" method. |
static void |
clearIsCdDriveCache(java.lang.String absolutePath)
Clears cache for "isCdDrive" method for specified file path. |
static void |
clearIsComputerCache()
Clears cache for "isComputer" method. |
static void |
clearIsComputerCache(java.lang.String absolutePath)
Clears cache for "isComputer" method for specified file path. |
static void |
clearIsDirectoryCache()
Clears cache for "isDirectory" method. |
static void |
clearIsDirectoryCache(java.lang.String absolutePath)
Clears cache for "isDirectory" method for specified file path. |
static void |
clearIsDriveCache()
Clears cache for "isDrive" method. |
static void |
clearIsDriveCache(java.lang.String absolutePath)
Clears cache for "isDrive" method for specified file path. |
static void |
clearIsFileCache()
Clears cache for "isFile" method. |
static void |
clearIsFileCache(java.lang.String absolutePath)
Clears cache for "isFile" method for specified file path. |
static void |
clearIsHiddenCache()
Clears cache for "isHidden" method. |
static void |
clearIsHiddenCache(java.lang.String absolutePath)
Clears cache for "isHidden" method for specified file path. |
static java.lang.String |
computeMD5(java.io.File file)
Returns MD5 for specified file. |
static java.lang.String |
computeMD5(java.io.File file,
int bufferLength)
Returns MD5 for specified file and using a buffer of specified length. |
static java.lang.String |
computeMD5(java.io.InputStream is)
Returns MD5 using the specified data stream. |
static java.lang.String |
computeMD5(java.io.InputStream is,
int bufferLength)
Returns MD5 using the specified data stream and a buffer of specified length. |
static boolean |
containtsFile(java.util.List files,
java.io.File file)
Returns whether list of files or file paths contains the specified file or not. |
static boolean |
copyDirectory(java.io.File srcDir,
java.io.File dstDir)
Copies src directory content into dst directory and returns whether operation succeed or not. |
static boolean |
copyDirectory(java.io.File srcDir,
java.io.File dstDir,
boolean stopOnFail)
Copies src directory content into dst directory and returns whether operation succeed or not. |
static boolean |
copyDirectory(java.lang.String src,
java.lang.String dst)
Copies src directory content into dst directory and returns whether operation succeed or not. |
static boolean |
copyDirectory(java.lang.String src,
java.lang.String dst,
boolean stopOnFail)
Copies src directory content into dst directory and returns whether operation succeed or not. |
static boolean |
copyFile(java.nio.channels.FileChannel srcFC,
java.nio.channels.FileChannel dstFC)
Copies file data from source file channel into destination file channel. |
static boolean |
copyFile(java.io.File srcFile,
java.io.File dstFile)
Copies source file content into destination file. |
static boolean |
copyFile(java.lang.String src,
java.lang.String dst)
Copies source file content into destination file. |
static FileDescription |
createFileDescription(java.io.File file,
java.lang.String fileSize)
Returns complete file description. |
static void |
deleteFile(java.io.File file)
Deletes file or directory completely. |
static void |
deleteFiles(java.util.List files)
Deletes all specified files. |
static void |
deleteFiles(java.lang.Object... files)
Deletes all specified files. |
static void |
displayFileName(javax.swing.text.JTextComponent editor,
java.io.File file)
Sets file name as text and selects its name part in any text component. |
static java.io.File |
downloadFile(java.lang.String url,
java.io.File dstFile)
Downloads file from the specified url to destination file and returns it if download succeed or null if not. |
static java.io.File |
downloadFile(java.lang.String url,
java.io.File dstFile,
boolean encodeUrl,
java.lang.String contentType,
int timeout)
Downloads file from the specified url to destination file and returns it if download succeed or null if not. |
static java.io.File |
downloadFile(java.lang.String url,
java.io.File dstFile,
boolean encodeUrl,
java.lang.String contentType,
int timeout,
FileDownloadListener listener)
Downloads file from the specified url to destination file and returns it if download succeed or null if not. |
static java.io.File |
downloadFile(java.lang.String url,
java.io.File dstFile,
FileDownloadListener listener)
Downloads file from the specified url to destination file and returns it if download succeed or null if not. |
static java.io.File |
downloadFile(java.lang.String url,
java.lang.String dst,
boolean encodeUrl,
java.lang.String contentType,
int timeout)
Downloads file from the specified url to destination file and returns it if download succeed or null if not. |
static java.io.File |
downloadFile(java.lang.String url,
java.lang.String dst,
boolean encodeUrl,
java.lang.String contentType,
int timeout,
FileDownloadListener listener)
Downloads file from the specified url to destination file and returns it if download succeed or null if not. |
static boolean |
ensureDirectoryExists(java.io.File dir)
Returns true if directory exists or was successfully created during this check, false otherwise. |
static boolean |
ensureDirectoryExists(java.lang.String dir)
Returns true if directory exists or was successfully created during this check, false otherwise. |
static boolean |
equals(java.io.File file1,
java.io.File file2)
Returns whether both files represent the same path in file system or not. |
static boolean |
equals(java.util.List<java.io.File> files1,
java.util.List<java.io.File> files2)
Returns whether both list of files have equal files in the same positions or not. |
static java.util.List<java.io.File> |
filterFiles(java.util.Collection<java.io.File> files,
AbstractFileFilter fileFilter)
Returns filtered files list. |
static java.util.List<java.io.File> |
findFilesRecursively(java.io.File dir,
java.io.FileFilter filter)
Returns list of files accepted by file filter found in the specified directory and its subdirectories. |
static java.util.List<java.io.File> |
findFilesRecursively(java.io.File dir,
java.io.FileFilter filter,
java.util.List<java.io.File> found)
Returns list of files accepted by file filter found in the specified directory and its subdirectories. |
static java.util.List<java.io.File> |
findFilesRecursively(java.io.File dir,
java.util.List<java.lang.String> extension)
Returns list of files with specified extensions found in the specified directory and its subdirectories. |
static java.util.List<java.io.File> |
findFilesRecursively(java.io.File dir,
java.util.List<java.lang.String> extension,
boolean withDot)
Returns list of files with specified extensions found in the specified directory and its subdirectories. |
static java.util.List<java.io.File> |
findFilesRecursively(java.io.File dir,
java.util.List<java.lang.String> extension,
boolean withDot,
java.util.List<java.io.File> found)
Returns list of files with specified extensions found in the specified directory and its subdirectories. |
static java.util.List<java.io.File> |
findFilesRecursively(java.lang.String dir,
java.io.FileFilter filter)
Returns list of files accepted by file filter found in the specified directory and its subdirectories. |
static java.util.List<java.io.File> |
findFilesRecursively(java.lang.String dir,
java.io.FileFilter filter,
java.util.List<java.io.File> found)
Returns list of files accepted by file filter found in the specified directory and its subdirectories. |
static java.util.List<java.io.File> |
findFilesRecursively(java.lang.String dir,
java.util.List<java.lang.String> extension)
Returns list of files with specified extensions found in the specified directory and its subdirectories. |
static java.util.List<java.io.File> |
findFilesRecursively(java.lang.String dir,
java.util.List<java.lang.String> extension,
boolean withDot)
Returns list of files with specified extensions found in the specified directory and its subdirectories. |
static java.util.List<java.io.File> |
findFilesRecursively(java.lang.String dir,
java.util.List<java.lang.String> extension,
boolean withDot,
java.util.List<java.io.File> found)
Returns list of files with specified extensions found in the specified directory and its subdirectories. |
static java.lang.String |
getAvailableName(java.io.File dir,
java.lang.String name)
Returns available file name in the specified directory and which is similar the specified name. |
static java.lang.String |
getAvailableName(java.util.List<java.lang.String> exist,
java.lang.String name)
Returns available file name that is not contained in the existing names list. |
static java.lang.String |
getAvailableName(java.lang.String dir,
java.lang.String name)
Returns available file name in the specified directory and which is similar the specified name. |
static java.io.File[] |
getDiskRoots()
Returns array of available system disks. |
static java.lang.String |
getDisplayFileCreationDate(java.io.File file)
Returns file modification date to display. |
static java.lang.String |
getDisplayFileModificationDate(java.io.File file)
Returns file modification date to display. |
static java.lang.String |
getDisplayFileName(java.io.File file)
Returns file name to display. |
static java.lang.String |
getDisplayFileSize(java.io.File file)
Returns file size to display. |
static java.lang.String |
getDisplayFileSize(java.io.File file,
int digits)
Returns file size to display. |
static FileDescription |
getFileDescription(java.io.File file,
java.lang.String fileSize)
Returns complete file description. |
static java.lang.String |
getFileExtPart(java.lang.String file,
boolean withDot)
Returns file extension either with or without dot. |
static javax.swing.ImageIcon |
getFileIcon(java.io.File file)
Returns system file icon. |
static javax.swing.ImageIcon |
getFileIcon(java.io.File file,
boolean large)
Returns either large or small system file icon. |
static java.lang.String |
getFileNamePart(java.io.File file)
Returns file name without extension. |
static java.lang.String |
getFileNamePart(java.lang.String name)
Returns file name without extension. |
static java.util.List<java.io.File> |
getFilePath(java.io.File file)
Returns list of files contained in path of the specified file. |
static int |
getFileSize(java.lang.String url)
Returns file size, located at the specified url. |
static int |
getFileSize(java.net.URL url)
Returns file size, located at the specified url. |
static java.lang.String |
getFileSizeString(long size)
Returns file size to display. |
static java.lang.String |
getFileSizeString(long size,
int digits)
Returns file size to display. |
static java.lang.String |
getFileTypeDescription(java.io.File file)
Returns file type description. |
static javax.swing.ImageIcon |
getIconResource(java.lang.Class nearClass,
java.lang.String resource)
Returns resource icon. |
static javax.swing.ImageIcon |
getIconResource(java.lang.Class nearClass,
java.lang.String resource,
float transparency)
Returns resource icon with the specified transparency. |
static javax.swing.ImageIcon |
getMyComputerIcon()
Returns default icon for "My computer" file. |
static java.lang.String |
getProperFileName(java.lang.String name)
Returns a valid for any file system file name based on specified name. |
static java.lang.String |
getRelativePath(java.io.File file,
java.io.File folder)
Returns file path relative to specified folder or canonical path if file is not inside that folder. |
static java.lang.String |
getShortFileName(java.lang.String name)
Returns shortened file name. |
static java.lang.String |
getShortFileName(java.lang.String name,
int length)
Returns shortened to the specified length file name. |
static javax.swing.ImageIcon |
getStandartFileIcon(boolean large,
java.lang.String extension,
float transparency)
Returns either large or small icon for the specified extension from a standard icons set. |
static javax.swing.ImageIcon |
getStandartFileIcon(java.io.File file,
boolean large)
Returns either large or small file icon from a standard icons set. |
static javax.swing.ImageIcon |
getStandartFileIcon(java.io.File file,
boolean large,
boolean enabled)
Returns either large or small file icon from a standard icons set. |
static java.util.List<java.lang.String> |
getSubpaths(java.io.File dir)
Returns list of all file paths in this directory and all subdirectories. |
static java.util.List<java.lang.String> |
getSubpaths(java.io.File dir,
java.lang.String path)
Returns list of all file paths in this directory and all subdirectories. |
static java.util.List<java.lang.String> |
getSubpaths(java.io.File dir,
java.lang.String path,
java.util.List<java.lang.String> paths)
Returns list of all file paths in this directory and all subdirectories. |
static java.util.List<java.lang.String> |
getSubpaths(java.lang.String dir)
Returns list of all file paths in this directory and all subdirectories. |
static java.io.File |
getSystemRoot()
Returns first available file system root. |
static java.io.File[] |
getSystemRoots()
Returns array of available file system roots. |
static java.io.File |
getSystemTemp()
Returns system directory for temporary files. |
static java.lang.String |
getSystemTempPath()
Returns path to system directory for temporary files. |
static java.io.File |
getTopParent(java.io.File file)
Returns top not-null parent for the specified file. |
static java.io.File |
getUserHome()
Returns user home directory. |
static java.lang.String |
getUserHomePath()
Returns path to user home directory. |
static java.io.File |
getWorkingDirectory()
Returns application working directory. |
static java.lang.String |
getWorkingDirectoryPath()
Returns application working directory. |
static boolean |
grantExecutePermissions(java.io.File file)
Grants file execution permission for all users for specified file. |
static boolean |
isCdDrive(java.io.File file)
Returns whether the specified file points to system CD/DVD/Bluray drive or not. |
static boolean |
isComputer(java.io.File file)
Returns whether the specified file points to system hard drive or not. |
static boolean |
isDirectory(java.io.File file)
Returns whether the specified file is directory or not. |
static boolean |
isDrive(java.io.File file)
Returns whether the specified file points to system hard drive or not. |
static boolean |
isFile(java.io.File file)
Returns whether the specified file is actually a file (and not a directory, disk or some system folder) or not. |
static boolean |
isFileAccepted(java.io.File file,
java.util.List<AbstractFileFilter> filters)
Returns whether any of the specified file filters accept the file or not. |
static boolean |
isHidden(java.io.File file)
Returns whether the specified file is hidden or not. |
static boolean |
isIllegalFileNameChar(char c)
Returns whether the specified character is illegal or not. |
static boolean |
isNameEditable(java.io.File file)
Returns whether specified file's name can be edited. |
static boolean |
isParent(java.io.File parent,
java.io.File child)
Returns whether the specified child file is one of parent file childs or not. |
static java.io.File[] |
listFiles(java.io.File directory,
java.io.FileFilter fileFilter)
Returns directory files array or empty array (instead of null) if no files present. |
static java.io.File |
normalize(java.io.File file)
Returns normalized file without redundant parts in its path. |
static java.lang.String |
readToString(java.lang.Class nearClass,
java.lang.String resource)
Returns text content read from the file located near specified class. |
static java.lang.String |
readToString(java.io.File file)
Returns text content read from the specified file. |
static java.lang.String |
readToString(java.io.InputStream inputStream)
Returns text content read from the input stream. |
static java.lang.String |
readToString(java.io.Reader reader)
Returns text content read from the specified reader. |
static java.lang.String |
readToString(java.net.URL url)
Returns text content read from the file at the specified url. |
static java.io.File[] |
sortFiles(java.io.File[] files)
Returns sorted array of files. |
static java.util.List |
sortFiles(java.util.List<java.io.File> files)
Returns sorted list of files. |
static java.util.List<java.io.File> |
toFilesList(java.lang.Object... object)
Converts objects array into list of files. |
static AbstractFileFilter |
transformFileFilter(java.io.FileFilter fileFilter)
Returns transformed file filter. |
static AbstractFileFilter |
transformFileFilter(javax.swing.filechooser.FileFilter fileFilter)
Returns transformed file filter. |
static void |
writeStringToFile(java.lang.String text,
java.io.File file)
Writes text to the specified file overwriting any content inside the file. |
static void |
writeStringToFile(java.lang.String text,
java.io.File file,
java.lang.String encoding)
Writes text to the specified file overwriting any content inside the file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long KB
public static final long MB
public static final long GB
public static final long PB
Constructor Detail |
---|
public FileUtils()
Method Detail |
---|
public static void clearFilesCaches(java.io.File... files)
files
- files to processpublic static void clearFileCaches(java.io.File file)
file
- file to processpublic static void clearFileCaches(java.lang.String path)
path
- file pathpublic static java.util.List<java.io.File> getFilePath(java.io.File file)
file
- file to process
public static java.lang.String getRelativePath(java.io.File file, java.io.File folder)
file
- file to get relative path tofolder
- one of file's parent folders
public static boolean isNameEditable(java.io.File file)
file
- file to edit
public static void displayFileName(javax.swing.text.JTextComponent editor, java.io.File file)
editor
- text editor to processfile
- file to processpublic static java.io.File getSystemTemp()
public static java.lang.String getSystemTempPath()
public static boolean grantExecutePermissions(java.io.File file)
file
- file for permissions change
public static java.io.File normalize(java.io.File file)
file
- file to normalize
public static java.io.File getSystemRoot()
public static java.io.File[] getSystemRoots()
public static java.io.File[] getDiskRoots()
public static java.io.File[] listFiles(java.io.File directory, java.io.FileFilter fileFilter)
directory
- directory to look intofileFilter
- file filter
public static java.lang.String computeMD5(java.io.File file)
file
- file to process
public static java.lang.String computeMD5(java.io.File file, int bufferLength)
file
- file to processbufferLength
- buffer length
public static java.lang.String computeMD5(java.io.InputStream is)
is
- data stream to process
public static java.lang.String computeMD5(java.io.InputStream is, int bufferLength)
is
- data stream to processbufferLength
- buffer length
public static java.io.File getWorkingDirectory()
public static java.lang.String getWorkingDirectoryPath()
public static java.io.File getUserHome()
public static java.lang.String getUserHomePath()
public static boolean equals(java.io.File file1, java.io.File file2)
file1
- first file to be comparedfile2
- second file to be compared
public static boolean equals(java.util.List<java.io.File> files1, java.util.List<java.io.File> files2)
files1
- first files list to be comparedfiles2
- second files list to be compared
public static boolean containtsFile(java.util.List files, java.io.File file)
files
- list of files to search infile
- file to look for
public static boolean isFileAccepted(java.io.File file, java.util.List<AbstractFileFilter> filters)
file
- file to processfilters
- file filters list
public static java.lang.String getProperFileName(java.lang.String name)
name
- name to process
public static boolean isIllegalFileNameChar(char c)
c
- character to process
public static java.lang.String canonicalPath(java.io.File file)
file
- file to process
public static java.io.File getTopParent(java.io.File file)
file
- file to process
public static boolean isParent(java.io.File parent, java.io.File child)
parent
- parent filechild
- child file
public static java.lang.String getFileNamePart(java.io.File file)
file
- file to process
public static java.lang.String getFileNamePart(java.lang.String name)
name
- file name to trim
public static java.lang.String getFileExtPart(java.lang.String file, boolean withDot)
file
- file to processwithDot
- whether return the extension with dot, or not
public static java.lang.String getShortFileName(java.lang.String name)
name
- file name to shorten
public static java.lang.String getShortFileName(java.lang.String name, int length)
name
- file name to shortenlength
- maximum allowed file name length
public static java.util.List sortFiles(java.util.List<java.io.File> files)
files
- list of files to sort
public static java.io.File[] sortFiles(java.io.File[] files)
files
- array of files to sort
public static java.lang.String getAvailableName(java.lang.String dir, java.lang.String name)
dir
- directory path to checkname
- file name to check
public static java.lang.String getAvailableName(java.io.File dir, java.lang.String name)
dir
- directory to checkname
- file name to check
public static java.lang.String getAvailableName(java.util.List<java.lang.String> exist, java.lang.String name)
exist
- list of existing file namesname
- file name to check
public static java.util.List<java.io.File> toFilesList(java.lang.Object... object)
object
- file object
public static void deleteFiles(java.lang.Object... files)
files
- files to deletepublic static void deleteFiles(java.util.List files)
files
- files to deletepublic static void deleteFile(java.io.File file)
file
- file to deletepublic static void clearDirectory(java.io.File dir)
dir
- directory to clearpublic static AbstractFileFilter transformFileFilter(java.io.FileFilter fileFilter)
fileFilter
- IO file filter
public static AbstractFileFilter transformFileFilter(javax.swing.filechooser.FileFilter fileFilter)
fileFilter
- Swing file filter
public static java.util.List<java.io.File> filterFiles(java.util.Collection<java.io.File> files, AbstractFileFilter fileFilter)
files
- files collection to filterfileFilter
- file filter
public static FileDescription createFileDescription(java.io.File file, java.lang.String fileSize)
file
- file to processfileSize
- file size
public static java.lang.String getDisplayFileSize(java.io.File file)
file
- file to process
public static java.lang.String getDisplayFileSize(java.io.File file, int digits)
file
- file to processdigits
- number of digits after the dot
public static java.lang.String getFileSizeString(long size)
size
- size of the file
public static java.lang.String getFileSizeString(long size, int digits)
size
- size of the filedigits
- number of digits after the dot
public static boolean copyDirectory(java.lang.String src, java.lang.String dst)
src
- source directory pathdst
- destination directory path
public static boolean copyDirectory(java.lang.String src, java.lang.String dst, boolean stopOnFail)
src
- source directory pathdst
- destination directory pathstopOnFail
- whether to stop copy operation if any exception occurs or not
public static boolean copyDirectory(java.io.File srcDir, java.io.File dstDir)
srcDir
- source directorydstDir
- destination directory
public static boolean copyDirectory(java.io.File srcDir, java.io.File dstDir, boolean stopOnFail)
srcDir
- source directorydstDir
- destination directorystopOnFail
- whether to stop copy operation if any exception occurs or not
public static boolean copyFile(java.lang.String src, java.lang.String dst)
src
- source file pathdst
- destination file path
public static boolean copyFile(java.io.File srcFile, java.io.File dstFile)
srcFile
- source filedstFile
- destination file
public static boolean copyFile(java.nio.channels.FileChannel srcFC, java.nio.channels.FileChannel dstFC)
srcFC
- source file channeldstFC
- destination file channel
public static java.lang.String readToString(java.lang.Class nearClass, java.lang.String resource)
nearClass
- class near which text file is locatedresource
- text file location
public static java.lang.String readToString(java.net.URL url)
url
- text file url
public static java.lang.String readToString(java.io.InputStream inputStream)
inputStream
- text content input stream
public static java.lang.String readToString(java.io.File file)
file
- file to read
public static java.lang.String readToString(java.io.Reader reader)
reader
- text content reader
public static void writeStringToFile(java.lang.String text, java.io.File file)
text
- text to writefile
- file to write text intopublic static void writeStringToFile(java.lang.String text, java.io.File file, java.lang.String encoding)
text
- text to writefile
- file to write text intopublic static java.util.List<java.lang.String> getSubpaths(java.lang.String dir)
dir
- path of directory to process
public static java.util.List<java.lang.String> getSubpaths(java.io.File dir)
dir
- directory to process
public static java.util.List<java.lang.String> getSubpaths(java.io.File dir, java.lang.String path)
dir
- directory to processpath
- path to current position
public static java.util.List<java.lang.String> getSubpaths(java.io.File dir, java.lang.String path, java.util.List<java.lang.String> paths)
dir
- directory to processpath
- path to current positionpaths
- list of collected paths
public static java.io.File downloadFile(java.lang.String url, java.io.File dstFile)
url
- file source urldstFile
- destination file
public static java.io.File downloadFile(java.lang.String url, java.io.File dstFile, FileDownloadListener listener)
url
- file source urldstFile
- destination filelistener
- file download process listener
public static java.io.File downloadFile(java.lang.String url, java.lang.String dst, boolean encodeUrl, java.lang.String contentType, int timeout)
url
- file source urldst
- destination file pathencodeUrl
- whether encode the source url or notcontentType
- content type limitationtimeout
- connection and read timeout
public static java.io.File downloadFile(java.lang.String url, java.lang.String dst, boolean encodeUrl, java.lang.String contentType, int timeout, FileDownloadListener listener)
url
- file source urldst
- destination file pathencodeUrl
- whether encode the source url or notcontentType
- content type limitationtimeout
- connection and read timeoutlistener
- file download process listener
public static java.io.File downloadFile(java.lang.String url, java.io.File dstFile, boolean encodeUrl, java.lang.String contentType, int timeout)
url
- file source urldstFile
- destination fileencodeUrl
- whether encode the source url or notcontentType
- content type limitationtimeout
- connection and read timeout
public static java.io.File downloadFile(java.lang.String url, java.io.File dstFile, boolean encodeUrl, java.lang.String contentType, int timeout, FileDownloadListener listener)
url
- file source urldstFile
- destination fileencodeUrl
- whether encode the source url or notcontentType
- content type limitationtimeout
- connection and read timeoutlistener
- file download process listener
public static int getFileSize(java.lang.String url)
url
- file location url
public static int getFileSize(java.net.URL url)
url
- file location url
public static java.util.List<java.io.File> findFilesRecursively(java.lang.String dir, java.util.List<java.lang.String> extension)
dir
- path to directory to processextension
- file extensions list
public static java.util.List<java.io.File> findFilesRecursively(java.io.File dir, java.util.List<java.lang.String> extension)
dir
- directory to processextension
- file extensions list
public static java.util.List<java.io.File> findFilesRecursively(java.lang.String dir, java.util.List<java.lang.String> extension, boolean withDot)
dir
- path to directory to processextension
- file extensions listwithDot
- whether extensions contain dot or not
public static java.util.List<java.io.File> findFilesRecursively(java.io.File dir, java.util.List<java.lang.String> extension, boolean withDot)
dir
- directory to processextension
- file extensions listwithDot
- whether extensions contain dot or not
public static java.util.List<java.io.File> findFilesRecursively(java.lang.String dir, java.util.List<java.lang.String> extension, boolean withDot, java.util.List<java.io.File> found)
dir
- path to directory to processextension
- file extensions listwithDot
- whether extensions contain dot or notfound
- list in which found files should be stored
public static java.util.List<java.io.File> findFilesRecursively(java.io.File dir, java.util.List<java.lang.String> extension, boolean withDot, java.util.List<java.io.File> found)
dir
- directory to processextension
- file extensions listwithDot
- whether extensions contain dot or notfound
- list in which found files should be stored
public static java.util.List<java.io.File> findFilesRecursively(java.lang.String dir, java.io.FileFilter filter)
dir
- path to directory to processfilter
- file filter
public static java.util.List<java.io.File> findFilesRecursively(java.io.File dir, java.io.FileFilter filter)
dir
- directory to processfilter
- file filter
public static java.util.List<java.io.File> findFilesRecursively(java.lang.String dir, java.io.FileFilter filter, java.util.List<java.io.File> found)
dir
- path to directory to processfilter
- file filterfound
- list in which found files should be stored
public static java.util.List<java.io.File> findFilesRecursively(java.io.File dir, java.io.FileFilter filter, java.util.List<java.io.File> found)
dir
- directory to processfilter
- file filterfound
- list in which found files should be stored
public static boolean ensureDirectoryExists(java.lang.String dir)
dir
- path to directory to check
public static boolean ensureDirectoryExists(java.io.File dir)
dir
- directory to check
public static void clearIsDriveCache()
public static void clearIsDriveCache(java.lang.String absolutePath)
public static boolean isDrive(java.io.File file)
file
- file to process
public static void clearIsComputerCache()
public static void clearIsComputerCache(java.lang.String absolutePath)
public static boolean isComputer(java.io.File file)
file
- file to process
public static void clearIsCdDriveCache()
public static void clearIsCdDriveCache(java.lang.String absolutePath)
public static boolean isCdDrive(java.io.File file)
file
- file to process
public static void clearIsFileCache()
public static void clearIsFileCache(java.lang.String absolutePath)
public static boolean isFile(java.io.File file)
file
- file to process
public static void clearIsDirectoryCache()
public static void clearIsDirectoryCache(java.lang.String absolutePath)
public static boolean isDirectory(java.io.File file)
file
- file to process
public static void clearIsHiddenCache()
public static void clearIsHiddenCache(java.lang.String absolutePath)
public static boolean isHidden(java.io.File file)
file
- file to process
public static void clearFileDescriptionCache()
public static void clearFileDescriptionCache(java.lang.String absolutePath)
public static FileDescription getFileDescription(java.io.File file, java.lang.String fileSize)
file
- file to processfileSize
- file size on disk
public static void clearDisplayFileNameCache()
public static void clearDisplayFileNameCache(java.lang.String absolutePath)
public static java.lang.String getDisplayFileName(java.io.File file)
file
- file to process
public static void clearDisplayFileCreationDateCache()
public static void clearDisplayFileCreationDateCache(java.lang.String absolutePath)
public static java.lang.String getDisplayFileCreationDate(java.io.File file)
file
- file to process
public static void clearDisplayFileModificationDateCache()
public static void clearDisplayFileModificationDateCache(java.lang.String absolutePath)
public static java.lang.String getDisplayFileModificationDate(java.io.File file)
file
- file to process
public static void clearFileTypeDescriptionCache()
public static void clearFileTypeDescriptionCache(java.lang.String absolutePath)
public static java.lang.String getFileTypeDescription(java.io.File file)
file
- file to process
public static javax.swing.ImageIcon getMyComputerIcon()
public static javax.swing.ImageIcon getFileIcon(java.io.File file)
file
- file to process
public static javax.swing.ImageIcon getFileIcon(java.io.File file, boolean large)
file
- file to processlarge
- whether return large icon or not
public static javax.swing.ImageIcon getStandartFileIcon(java.io.File file, boolean large)
file
- file to processlarge
- whether return large icon or not
public static javax.swing.ImageIcon getStandartFileIcon(java.io.File file, boolean large, boolean enabled)
file
- file to processlarge
- whether return large icon or not
public static javax.swing.ImageIcon getStandartFileIcon(boolean large, java.lang.String extension, float transparency)
large
- whether return large icon or notextension
- file extensiontransparency
- icon transparency
public static javax.swing.ImageIcon getIconResource(java.lang.Class nearClass, java.lang.String resource)
nearClass
- class near which the icon is locatedresource
- icon location
public static javax.swing.ImageIcon getIconResource(java.lang.Class nearClass, java.lang.String resource, float transparency)
nearClass
- class near which the icon is locatedresource
- icon locationtransparency
- custom icon transparency
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |