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 java.io.File |
getNewFileName(java.io.File baseFolder,
java.lang.String name)
Create
File instance for a new file on a baseFolder
starts with baseName. |
static java.io.File |
getNewWritableFolder(java.io.File baseFolder,
java.lang.String baseName)
Create a new folder on a
baseFolder starts with
baseName which is new and writable. |
static java.io.File |
getRelativeTo(java.io.File path,
java.io.File basePath)
Return
path as relative from basePath only if
basePath is an ancestor of path:
|
static java.io.File |
getWritableFolder(java.io.File baseFolder,
java.lang.String baseName)
Look for a folder on a
baseFolder starts with
baseName which is writable. |
static boolean |
isReadableFile(java.io.File folder)
Informs if
file is a readable file ( exists & isFile &
canRead) |
static boolean |
isReadableFolder(java.io.File folder)
Informs if
folder is a readable folder( exists & isDir &
canRead) |
static boolean |
isWritableFolder(java.io.File folder)
Informs if
folder is a writable folder( exists & isDir &
canWrite) |
static void |
unzipFile(java.io.File zipFile,
java.io.File outputFloder)
Unzip a file into a folder
|
static void |
zipFolder(java.io.File rootFolder,
java.io.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(java.io.File zipFile,
java.io.File outputFloder)
throws java.util.zip.ZipException,
java.io.IOException
Unzip a file into a folder
zipFile - outputFloder - must exists. WARNING: Contents will be removed before
unzipjava.io.IOExceptionjava.util.zip.ZipExceptionjava.lang.IllegalArgumentException - if zipFile is not a file or outputFloder doesn't exists or is
read-onlypublic static void zipFolder(java.io.File rootFolder,
java.io.File targetFile)
throws java.io.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)java.io.IOExceptionjava.lang.IllegalArgumentException - if there are any problem in parameterspublic static boolean isWritableFolder(java.io.File folder)
folder is a writable folder( exists & isDir &
canWrite)folder - public static boolean isReadableFolder(java.io.File folder)
folder is a readable folder( exists & isDir &
canRead)folder - public static boolean isReadableFile(java.io.File folder)
file is a readable file ( exists & isFile &
canRead)folder - public static java.io.File getWritableFolder(java.io.File baseFolder,
java.lang.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 folderjava.lang.IllegalArgumentException - if base folder is not a writable folderjava.lang.IllegalStateException - if can't found a suitable folderpublic static java.io.File getNewWritableFolder(java.io.File baseFolder,
java.lang.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 folderjava.lang.IllegalArgumentException - if base folder is not a writable folderjava.lang.IllegalStateException - if can't found a suitable folderpublic static java.io.File getNewFileName(java.io.File baseFolder,
java.lang.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 filejava.lang.IllegalArgumentException - if base folder is not a writable folderjava.lang.IllegalStateException - if can't found a suitable folderpublic static java.io.File getRelativeTo(java.io.File path,
java.io.File basePath)
Return path as relative from basePath only if
basePath is an ancestor of path:
path - basePath - FilenameUtils.getRelativeTo(String, String)