|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jfw.file.FileUtils
public final class FileUtils
File utils methods. All methods are static and thread safe.
| Field Summary | |
|---|---|
static int |
TYPE_ALL
All files and dirs must be elaborated. |
static int |
TYPE_DIRS
Only dirs must be elaborated. |
static int |
TYPE_FILES
Only files must be elaborated. |
| Constructor Summary | |
|---|---|
FileUtils()
|
|
| Method Summary | |
|---|---|
static void |
copyFile(java.lang.String source,
java.lang.String name,
java.lang.String target,
java.lang.String newName,
boolean isText)
Copy a file from one directory to an other. |
static void |
createPath(java.lang.String path)
Create a path. |
static boolean |
delete(java.lang.String path)
Delete a file or directory |
static boolean |
deleteFile(java.lang.String pathAndName)
Delete a file. |
static boolean |
deleteFile(java.lang.String path,
java.lang.String name)
Delete a file. |
static boolean |
exists(java.lang.String fileName)
Check if a file exist. |
static java.util.ArrayList |
getDirElements(java.lang.String directory,
int type)
Get all elements in path, order by name. |
static java.util.ArrayList |
getDirElementsNames(java.util.ArrayList dirElements)
Get all elements in path, order by name. |
static java.util.ArrayList |
getRootElements()
Get root directories, order by name. |
static java.lang.String |
getUniqueName()
Get a randomly unique name. |
static boolean |
isDirectory(java.lang.String path)
Check if given path is a file or a dir. |
static boolean |
isFile(java.lang.String path)
Check if given path is a file or a dir. |
static void |
moveFile(java.lang.String source,
java.lang.String name,
java.lang.String target,
java.lang.String newName,
boolean isText)
Move a file from one directory to an other. |
static void |
moveFiles(java.lang.String sourcePath,
java.lang.String targetPath,
boolean isText)
Move a file from one directory to an other. |
static java.lang.String |
normalizePath(java.lang.String path)
Trim the given String and if is need add the separator char at the end. |
static void |
readAndWriteBinaryFile(ReadFile readFile,
java.io.OutputStream outputStream,
Encryption encryption)
Read a binary file and write it in an output stream. |
static boolean |
rename(java.lang.String source,
java.lang.String destination)
Rename a file or directory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int TYPE_ALL
public static final int TYPE_DIRS
public static final int TYPE_FILES
| Constructor Detail |
|---|
public FileUtils()
| Method Detail |
|---|
public static boolean isFile(java.lang.String path)
throws JFWGenericException
path - the path to check.
JFWGenericException
public static boolean isDirectory(java.lang.String path)
throws JFWGenericException
path - the path to check.
JFWGenericException
public static java.util.ArrayList getDirElements(java.lang.String directory,
int type)
throws JFWGenericException
directory - the path of a directory.type - one of the values of attributes TYPE_ALL, TYPE_DIRS
and TYPE_FILES. Only this type of directory elements is returned.
TYPE_ALL
or TYPE_DIRS). In index 0 the directory set in parameter
directory (if type is TYPE_ALL or TYPE_DIRS).
JFWGenericException
public static java.util.ArrayList getDirElementsNames(java.util.ArrayList dirElements)
throws JFWGenericException
dirElements - an ArrayList of File returned by getDirElements(java.lang.String, int).
JFWGenericException
public static java.util.ArrayList getRootElements()
throws JFWGenericException
JFWGenericExceptionpublic static boolean exists(java.lang.String fileName)
public static void createPath(java.lang.String path)
path - the path to create.
public static void copyFile(java.lang.String source,
java.lang.String name,
java.lang.String target,
java.lang.String newName,
boolean isText)
throws JFWGenericException
source - source path of file.name - file name.target - target path to copy.newName - name of file in target path. If null the original name is used.isText - true if is a text file, false if is a binary file.
JFWGenericException
public static void moveFiles(java.lang.String sourcePath,
java.lang.String targetPath,
boolean isText)
throws JFWGenericException
sourcePath - source path and file name of file.targetPath - target path and file name of file.isText - true if is a text file, false if is a binary file.
JFWGenericException
public static void moveFile(java.lang.String source,
java.lang.String name,
java.lang.String target,
java.lang.String newName,
boolean isText)
throws JFWGenericException
source - source path of file.name - file name.target - target path to copy.newName - name of file in target path. If null the original name is used.isText - true if is a text file, false if is a binary file.
JFWGenericException
public static boolean deleteFile(java.lang.String path,
java.lang.String name)
path - path of file.name - file name.
public static boolean deleteFile(java.lang.String pathAndName)
pathAndName - path and name of a file.
public static boolean delete(java.lang.String path)
path - if this path is a directory then all subdirectories and files
will also delete.
public static java.lang.String normalizePath(java.lang.String path)
path - path to change.
public static java.lang.String getUniqueName()
public static boolean rename(java.lang.String source,
java.lang.String destination)
source - the absolute name of the file/directory to rename.destination - the absolute name of the new renamed file/directory.
public static void readAndWriteBinaryFile(ReadFile readFile,
java.io.OutputStream outputStream,
Encryption encryption)
throws JFWGenericException
readFile - the file to read.outputStream - the output stream to write.encryption - an Encryption object. Set to
null if you don't need to encrypt the data.
JFWGenericException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||