public abstract class FileUtils
extends org.apache.commons.io.FileUtils
File utilities. Extends the provides by apache-common-IO
| Modifier and Type | Field and Description |
|---|---|
static boolean |
UNIXLIKE_FILESYSTEM |
| Constructor and Description |
|---|
FileUtils() |
| Modifier and Type | Method and Description |
|---|---|
static File |
getNewFileName(File baseFolder,
String name)
|
static File |
getNewWritableFolder(File baseFolder,
String baseName)
Create a new folder on a
baseFolder starts with
baseName which is new and writable. |
static File |
getRelativeTo(File path,
File basePath)
Return
path as relative from basePath only if
basePath is an ancestor of path:
|
static File |
getWritableFolder(File baseFolder,
String baseName)
Look for a folder on a
baseFolder starts with
baseName which is writable. |
static boolean |
isReadableFile(File folder)
Informs if
file is a readable file ( exists & isFile &
canRead) |
static boolean |
isReadableFolder(File folder)
Informs if
folder is a readable folder( exists & isDir &
canRead) |
static boolean |
isWritableFolder(File folder)
Informs if
folder is a writable folder( exists & isDir &
canWrite) |
static void |
unzipFile(File zipFile,
File outputFloder)
Unzip a file into a folder
|
static void |
zipFolder(File rootFolder,
File targetFile)
Create a zip file which will contains all contents of a folder
Files will be use relative path to
rootFolder
|
public static void unzipFile(File zipFile, File outputFloder) throws ZipException, IOException
Unzip a file into a folder
zipFile - outputFloder - must exists. WARNING: Contents will be removed before
unzipIOExceptionZipExceptionIllegalArgumentException - if zipFile is not a file or outputFloder doesn't exists or is
read-onlypublic static void zipFolder(File rootFolder, File targetFile) throws IOException
Create a zip file which will contains all contents of a folder
Files will be use relative path to rootFolder
rootFolder - rootFolder (must be an existing folder)targetFile - final file (must not exists)IOExceptionIllegalArgumentException - if there are any problem in parameterspublic static boolean isWritableFolder(File folder)
folder is a writable folder( exists & isDir &
canWrite)folder - public static boolean isReadableFolder(File folder)
folder is a readable folder( exists & isDir &
canRead)folder - public static boolean isReadableFile(File folder)
file is a readable file ( exists & isFile &
canRead)folder - public static File getWritableFolder(File baseFolder, String baseName)
Look for a folder on a baseFolder starts with
baseName which is writable.
The pattern is: baseFolder/baseName.0000 where
000 it's a counter.
baseFolder - existing and writable folderbaseName - start of new folderIllegalArgumentException - if base folder is not a writable folderIllegalStateException - if can't found a suitable folderpublic static File getNewWritableFolder(File baseFolder, String baseName)
Create a new folder on a baseFolder starts with
baseName which is new and writable.
The pattern is: baseFolder/baseName.0000 where
000 it's a counter.
baseFolder - existing and writable folderbaseName - start of new folderIllegalArgumentException - if base folder is not a writable folderIllegalStateException - if can't found a suitable folderpublic static File getNewFileName(File baseFolder, String name)
Create File instance for a new file on a baseFolder
starts with baseName.
The pattern is: baseFolder/baseName.0000.ext where
000 it's a counter.
This no create the file into the file system.
baseFolder - existing and writable foldername - start of new fileIllegalArgumentException - if base folder is not a writable folderIllegalStateException - if can't found a suitable folderpublic static File getRelativeTo(File path, File basePath)
Return path as relative from basePath only if
basePath is an ancestor of path:
path - basePath - FilenameUtils.getRelativeTo(String, String)