|
Dashboard Builder Commons 6.0.0.Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.dashboard.commons.io.FileUtil
public class FileUtil
Utilities to work with files.
| Method Summary | |
|---|---|
static void |
appendToFile(byte[] contents,
String filename)
Append content to a file |
static void |
appendToFile(String contents,
String filename)
Append content to a file |
static String |
changeSeparator(String p)
Changes File.separator into a Windows path to Unix path and vice versa. |
static long |
compFileDate(String fileName1,
String fileName2)
Test if the time a file was last modified is before, after or equals than the time another file was last modified |
static void |
copyFile(InputStream in,
String destFile)
Copy a file to another file using a static buffer of DEFAULT_BUFFER_SIZE |
static void |
copyFile(InputStream in,
String destFile,
int copyBufferSize)
Copy a file to another file using a buffer of maximum size |
static void |
copyFile(String sourceFile,
String destFile)
Copy a file to another file using a static buffer of DEFAULT_BUFFER_SIZE |
static void |
copyFile(String sourceFile,
String destFile,
int copyBufferSize)
Copy a file to another file using a buffer of maximum size |
static String |
createDir(String dirName)
Creates the directory named by a pathname, if it doesn't exists, including any necessary but nonexistent parent directories. |
static void |
deleteFile(String fileName)
Delete the file or directory denoted by a pathname. |
static boolean |
existFile(String fileName)
Test whether the file denoted by a pathname exists |
static String |
getTemporalFileName(String filePath)
Gets a non existing filename in the directory passed as a parameter. |
static boolean |
isDirectory(String path)
Check if a directory exists and is a directory. |
static boolean |
isUpdateFile(String fileName1,
String fileName2)
Test if the second file was the last modified |
static void |
makeBackupFile(String fileName)
Make a backup copy of a file denoted by a pathname, renaming the original file into a *.bak file. |
static void |
moveFile(InputStream in,
String destFile)
Move a file to another file using a static buffer of DEFAULT_BUFFER_SIZE |
static void |
moveFile(InputStream in,
String destFile,
int moveBufferSize)
Move a file to another file using a buffer of maximum size |
static void |
moveFile(String sourceFile,
String destFile)
MOve a file to another file using a static buffer of DEFAULT_BUFFER_SIZE |
static void |
moveFile(String sourceFile,
String destFile,
int moveBufferSize)
MOve a file to another file using a buffer of maximum size |
static byte[] |
readFile(String filename)
Read a file into a buffer sized the size of the file |
static byte[] |
readFromInputStream(InputStream is)
Reads a set of bytes from an InputStream and returns the data as a byte array. |
static Vector |
readLines(String file)
Read all lines of text in a file. |
static byte[] |
readResourceFile(String fileName)
Tries to read a file from disk, if it doesn't exist try to read from the CLASSPATH. |
static void |
renameFile(String oldFileName,
String newFileName)
Rename a file |
static void |
replace(String file,
String newfile,
String[] cads,
String[] newcads)
Replace the ocurrences of a list of strings in a File with new strings |
static void |
replace(String file,
String newfile,
String cad,
String newcad)
Replace the ocurrences of a string in a File with new string |
static void |
restoreBackupFile(String fileName)
Restore a backup copy of a file denoted by a pathname, renaming the backup file (*.bak) into a original file. |
static boolean |
swapFile(String source,
String tmp)
From an existing source file, and an existing temporal file, copy, in a trunc way, the temporal in place of the source file, and remove the temporal file |
static void |
writeLines(Vector lines,
String file,
boolean append)
Write an array of strings to the specified file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static boolean existFile(String fileName)
fileName - File pathname
public static long compFileDate(String fileName1,
String fileName2)
fileName1 - First file pathnamefileName2 - Second file pathname
public static boolean isUpdateFile(String fileName1,
String fileName2)
fileName1 - First file pathnamefileName2 - Second file pathname
public static void renameFile(String oldFileName,
String newFileName)
oldFileName - Old file namenewFileName - New file namepublic static void deleteFile(String fileName)
fileName - File pathname
public static void replace(String file,
String newfile,
String cad,
String newcad)
throws IOException
file - Source filenewfile - Destination file. If this parameter is 'null'
the changes are stored in the source file.cad - String to replacenewcad - New string
IOException
public static void replace(String file,
String newfile,
String[] cads,
String[] newcads)
throws IOException
file - Source filenewfile - Destination file. If this parameter is 'null'
the changes are stored in the source file.cads - String list to replacenewcads - New string list
IOExceptionpublic static void makeBackupFile(String fileName)
fileName - File pathnamepublic static void restoreBackupFile(String fileName)
fileName - File pathname
public static byte[] readFile(String filename)
throws FileNotFoundException,
IOException
filename - The file full-path
FileNotFoundException
IOException
public static byte[] readResourceFile(String fileName)
throws FileNotFoundException,
IOException
fileName - The file full-path or file name (to search into
CLASSPATH)
FileNotFoundException
IOException
public static byte[] readFromInputStream(InputStream is)
throws IOException
is - InputStream
IOException
public static Vector readLines(String file)
throws IOException
file - File pathname
IOException
public static void writeLines(Vector lines,
String file,
boolean append)
throws IOException
lines - array of strings to writefile - file pathnameappend - if true the lines will be written to the end of file,
otherwise they will be written to the begin of file and
the file is truncated.
IOException
public static void appendToFile(String contents,
String filename)
throws FileNotFoundException,
IOException
contents - the contentfilename - the file full-path
FileNotFoundException
IOException
public static void appendToFile(byte[] contents,
String filename)
throws FileNotFoundException,
IOException
contents - the contentfilename - the file full-path
FileNotFoundException
IOException
public static boolean swapFile(String source,
String tmp)
source - the existing source file, where to copy the information
from the existing temporal filetmp - the existing temporal file from where to copy the data
into the source file
public static void copyFile(InputStream in,
String destFile)
throws IOException
in - Source data streamdestFile - Destination file
IOException
public static void copyFile(String sourceFile,
String destFile)
throws IOException
sourceFile - Source filedestFile - Destination file
IOException
public static void copyFile(String sourceFile,
String destFile,
int copyBufferSize)
throws IOException
sourceFile - Source filedestFile - Destination filecopyBufferSize - Maximum size of the buffer
IOException
public static void copyFile(InputStream in,
String destFile,
int copyBufferSize)
throws IOException
in - Source data streamdestFile - Destination filecopyBufferSize - Maximum size of the buffer
IOException
public static void moveFile(String sourceFile,
String destFile)
throws IOException
sourceFile - Source filedestFile - Destination file
IOException
public static void moveFile(InputStream in,
String destFile)
throws IOException
in - Source data streamdestFile - Destination file
IOException
public static void moveFile(String sourceFile,
String destFile,
int moveBufferSize)
throws IOException
sourceFile - Source filedestFile - Destination filemoveBufferSize - Maximum size of the buffer
IOException
public static void moveFile(InputStream in,
String destFile,
int moveBufferSize)
throws IOException
in - Source data streamdestFile - Destination filemoveBufferSize - Maximum size of the buffer
IOExceptionpublic static String createDir(String dirName)
dirName - Directory pathname
public static boolean isDirectory(String path)
path - the path of the directory to be checked.
public static String getTemporalFileName(String filePath)
filePath - The path where is going to be placed the file.
public static String changeSeparator(String p)
p - String which contains the path
|
Dashboard Builder Commons 6.0.0.Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||