|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.gridsystems.utils.FileUtils
public final class FileUtils
General File Utilities.
| Nested Class Summary | |
|---|---|
static interface |
FileUtils.UnzipListener
Listener used to show information of unzipping process. |
| Field Summary | |
|---|---|
static int |
FOUR_KB_IN_BYTES
Four KB in bytes. |
static int |
ONE_KB_IN_BYTES
Oner KB in bytes. |
static int |
THIRTY_TWO_KB_IN_BYTES
Four KB in bytes. |
| Method Summary | |
|---|---|
static java.lang.Integer |
chmod(java.lang.String perms,
java.io.File f,
boolean recursive)
Equivalent to Unix chmod command. |
static void |
close(java.lang.Object obj)
Closes any object having a close() method without exceptions. |
static void |
copy(java.io.File ffrom,
java.io.File fto)
Copy a file from ffrom to fto. |
static boolean |
copyDir(java.io.File srcDir,
java.io.File dstDir)
Copia el contenido del directorio src_dir dentro del directorio dst_dir Si dst_dir no existe entonces lo crea. |
static boolean |
copyDirNative(java.io.File srcDir,
java.io.File dstDir)
Recursively copies the contents of srcDir into dstDir using external native commands. |
static boolean |
copyNative(java.io.File srcFile,
java.io.File dstFile)
Copies the file src_file into dst_file using native (O.S.) calls. |
static void |
copyStream(java.io.OutputStream dst,
java.io.InputStream src)
Copies a stream into another. |
static void |
createFile(java.io.InputStream srcIn,
java.io.File dstFile)
Copies the content of the input stream srcIn into the file dstFile. |
static void |
fileToStream(java.io.File file,
java.io.OutputStream dest)
Writes the contents of a file to an stream. |
static long |
getDirectorySize(java.io.File f,
java.io.FileFilter filter)
Finds out the size of all files within the specified directory, including subdirectories. |
static java.util.Properties |
loadPropertiesFromFile(java.io.File f)
Read properties from a file. |
static java.util.Properties |
mergeProperties(java.util.Properties base,
java.util.Properties olds)
Merge 2 properties into one. |
static void |
move(java.io.File src,
java.io.File dst)
Moves the contents of srcFile into dstFile. |
static boolean |
moveNative(java.io.File fsrc,
java.io.File fdst)
Moves a source file to a destination by calling a native command. |
static java.lang.String[] |
readListFile(java.io.File f)
Reads a text file containing a string item by line, and returns an array containing those lines not beginning by a '#' character. |
static java.lang.String |
readText(java.io.File f)
Reads the content of the text file and returns it as a String. |
static boolean |
rmtree(java.io.File f)
If f is a file then deletes it; if it is a directory then deletes its files and subdirectories, and after that, tries to delete it. |
static boolean |
rmtreeNative(java.io.File dir)
If parameter file is a file then delete this file. |
static void |
savePropertiesToFile(java.io.File f,
java.util.Properties props,
java.lang.String header)
Stores properties to a file. |
static void |
unzip(java.io.File dir,
java.io.File f,
boolean stripPrefix)
Uncompresses the specified file into the specified directory. |
static void |
unzip(java.io.File dir,
java.io.File f,
boolean stripPrefix,
FileUtils.UnzipListener unziplistener)
Uncompresses the specified file into the specified directory. |
static void |
unzip(java.io.File dir,
java.io.File f,
boolean stripPrefix,
FileUtils.UnzipListener unziplistener,
java.io.FileFilter filefilter)
Uncompresses the specified file into the specified directory. |
static void |
unzip(java.io.File dir,
java.io.File f,
java.io.FileFilter filter)
Uncompresses the specified file into the specified directory filtering by filter. |
static void |
unzip(java.io.File dir,
java.io.File f,
FileUtils.UnzipListener unziplistener)
Uncompresses the specified file into the specified directory. |
static void |
unzip(java.io.InputStream is,
java.io.File dir)
Uncompresses the specified stream into the specified directory. |
static void |
writeText(java.io.File f,
java.lang.String text)
Writes text into a file. |
static void |
zip(java.io.File dst,
java.io.File base,
java.io.File src,
java.io.FileFilter filter)
Crea un archivo zip del contenido de la raiz de cierto directorio. |
static void |
zip(java.io.File zip,
java.io.File filetozip,
java.io.FileFilter filter)
Crea un archivo zip del contenido de la raiz de cierto directorio. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int ONE_KB_IN_BYTES
public static final int FOUR_KB_IN_BYTES
public static final int THIRTY_TWO_KB_IN_BYTES
| Method Detail |
|---|
public static void close(java.lang.Object obj)
obj - The object to close
public static void savePropertiesToFile(java.io.File f,
java.util.Properties props,
java.lang.String header)
throws java.io.IOException
f - The destination fileprops - The source propertiesheader - The header line text
java.io.IOException - If an error occurs
public static java.util.Properties loadPropertiesFromFile(java.io.File f)
throws java.io.IOException
f - The file to read
java.io.IOException - If an error occurs
public static java.util.Properties mergeProperties(java.util.Properties base,
java.util.Properties olds)
base - the first Properties objectolds - the second Properties object
public static java.lang.String readText(java.io.File f)
throws java.io.IOException
f - the file to read from
java.io.IOException - if error
public static java.lang.String[] readListFile(java.io.File f)
throws java.io.IOException
f - The file to read
java.io.IOException - if error
public static void writeText(java.io.File f,
java.lang.String text)
throws java.io.IOException
f - the file to write totext - the text to be written
java.io.IOException - if error
public static void zip(java.io.File zip,
java.io.File filetozip,
java.io.FileFilter filter)
throws java.lang.Exception
zip - Archivo donde guardar el directorio comprimidofiletozip - archivo de directorio a comprimirfilter - filtro a aplicar para la selecciona de archivos a comprimir
java.lang.Exception - if error
public static void zip(java.io.File dst,
java.io.File base,
java.io.File src,
java.io.FileFilter filter)
throws java.io.IOException
dst - Archivo donde guardar el directorio comprimidobase - Directorio base a partir del cual apareceran las rutas en los
archivossrc - archivo de directorio a comprimirfilter - filtro a aplicar para la selecciona de archivos a comprimir
java.io.IOException - if error
public static void unzip(java.io.File dir,
java.io.File f,
boolean stripPrefix)
throws java.io.IOException
dir - The directory into which to unzipf - The file to unzipstripPrefix - Flag that controls if the path prefix is stripped from entries
java.io.IOException - If an error occurs
public static void unzip(java.io.File dir,
java.io.File f,
FileUtils.UnzipListener unziplistener)
throws java.io.IOException
dir - The directory into which to unzipf - The file to unzipunziplistener - Listenr for know status of unzipping
java.io.IOException - If an error occurs
public static void unzip(java.io.File dir,
java.io.File f,
java.io.FileFilter filter)
throws java.io.IOException
dir - The directory into which to unzipf - The file to unzipfilter - Filter files to extract (Only files, not directories)
java.io.IOException - If an error occurs
public static void unzip(java.io.File dir,
java.io.File f,
boolean stripPrefix,
FileUtils.UnzipListener unziplistener)
throws java.io.IOException
dir - The directory into which to unzipf - The file to unzipstripPrefix - Flag that controls if the path prefix is stripped from entriesunziplistener - Listenr for know status of unzipping
java.io.IOException - If an error occurs
public static void unzip(java.io.File dir,
java.io.File f,
boolean stripPrefix,
FileUtils.UnzipListener unziplistener,
java.io.FileFilter filefilter)
throws java.io.IOException
dir - The directory into which to unzipf - The file to unzipstripPrefix - Flag that controls if the path prefix is stripped from entriesunziplistener - Listenr for know status of unzippingfilefilter - Filter files to extract (Only files, not directories)
java.io.IOException - If an error occurs
public static void unzip(java.io.InputStream is,
java.io.File dir)
throws java.lang.Exception
The stream contents is supposed to be a zip file.
is - The stream for reading the zipdir - The directory into which to unzip
java.lang.Exception - if errorpublic static boolean rmtree(java.io.File f)
f - the file or directory to remove
public static boolean rmtreeNative(java.io.File dir)
dir - the directory to remove
public static void copyStream(java.io.OutputStream dst,
java.io.InputStream src)
throws java.io.IOException
dst - the destination streamsrc - the source stream
java.io.IOException - if error
public static void createFile(java.io.InputStream srcIn,
java.io.File dstFile)
throws java.io.IOException
srcIn - source input stream for the copy operationdstFile - destination file for the copy operation
java.io.IOException - if error
public static boolean copyDirNative(java.io.File srcDir,
java.io.File dstDir)
throws java.lang.Exception
Recursively copies the contents of srcDir into dstDir using external native commands.
If dstDir does not exists, it is created.
srcDir - Source directorydstDir - Destination directory
java.lang.Exception - If the native command could not be executed
public static boolean copyNative(java.io.File srcFile,
java.io.File dstFile)
throws java.io.IOException
srcFile - source file for the copy operationdstFile - destination file for the copy operation
java.io.IOException - If an error occurs
public static boolean copyDir(java.io.File srcDir,
java.io.File dstDir)
throws java.io.IOException
srcDir - fuentedstDir - destino
java.io.IOException - if error
public static void copy(java.io.File ffrom,
java.io.File fto)
throws java.io.IOException
ffrom - the source filefto - the dest file
java.io.IOException - if error
public static void move(java.io.File src,
java.io.File dst)
throws java.io.IOException
src - source file for the move operationdst - destination file for the move operation
java.io.IOException - if error
public static boolean moveNative(java.io.File fsrc,
java.io.File fdst)
fsrc - The source pathfdst - The destination path
public static long getDirectorySize(java.io.File f,
java.io.FileFilter filter)
f - the file or directoryfilter - the filter for the contents of the directory
public static java.lang.Integer chmod(java.lang.String perms,
java.io.File f,
boolean recursive)
perms - The permissions to set. It can be in the form "u+x" or in octalf - The file to set permissions onrecursive - recursive behaviour
public static void fileToStream(java.io.File file,
java.io.OutputStream dest)
throws java.io.IOException
file - the File that is read.dest - the OutputStream where the contents of file are
written.
java.io.IOException - if error
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||