| java.lang.Object com.jat.util.file.FileUtil
FileUtil | public class FileUtil (Code) | | Title: JAT
Description:
Copyright: Copyright (c) 2004 -2005 Stefano Fratini (stefano.fratini@gmail.com)
Distributed under the terms of the GNU Lesser General Public License, v2.1 or later
author: stf version: 1.1 |
Method Summary | |
public static void | copy(String sourceFile, String targetFile, boolean force) Copy the file sourceFile to the file targetFile. | public static void | copy(File sourceFile, File targetFile, boolean force) Copy the file sourceFile to the file targetFile. | protected static void | copyDir(File sourceFile, File targetFile, boolean force) Copy the entire directory sourceFile to the directory targetFile. | public static void | deleteDirectory(File dir) | public static Vector | getDirectories(String dir) | public static Vector | getDirectoryNames(String dir) | public static Vector | getFileNames(String dir) | public static Vector | getFileNames(String dir, boolean includeDirectory) | public static Vector | getFiles(String dir) | public static Vector | getFiles(String dir, boolean includeDirectory) | public static Vector | getFiles(String dir, boolean files, boolean includeDir, boolean name) Return the list of files and/or subdirectories of directory dir. | public static String | read(BufferedReader reader) | public static String | readFile(String file) | public static String | readFile(File file) | public static void | saveFile(String file, StringWriter sw) | public static void | saveFile(String file, String string) | public static void | saveFile(String file, byte[] bytes) | public static void | saveFile(File file, byte[] bytes) |
copy | public static void copy(String sourceFile, String targetFile, boolean force) throws FileNotFoundException, IOException(Code) | | Copy the file sourceFile to the file targetFile.
If sourceFile is a directoty, copy the entire contents of sourceFile into targetFile directory
Parameters: sourceFile - the source file or directory Parameters: targetFile - the source file or directory Parameters: force - used to force overwriting of existent file (or files into directory and subdirectories) throws: FileNotFoundException - if sourceFile does not exist throws: IOException - if source file exists and force is false or if any I/O error occours |
copy | public static void copy(File sourceFile, File targetFile, boolean force) throws FileNotFoundException, IOException(Code) | | Copy the file sourceFile to the file targetFile.
If sourceFile is a directoty, copy the entire contents of sourceFile into targetFile directory
Parameters: sourceFile - the source file or directory Parameters: targetFile - the source file or directory Parameters: force - used to force overwriting of existent file (or files into directory and subdirectories) throws: FileNotFoundException - if sourceFile does not exist throws: IOException - if source file exists and force is false or if any I/O error occours |
copyDir | protected static void copyDir(File sourceFile, File targetFile, boolean force) throws FileNotFoundException, IOException(Code) | | Copy the entire directory sourceFile to the directory targetFile.
Parameters: sourceFile - the source directory Parameters: targetFile - the source directory Parameters: force - used to force overwriting of existent files of directory and subdirectories throws: FileNotFoundException - if sourceFile directory does not exist throws: IOException - if at least a file of targetFile directory exists and force is false or if any I/O error occours |
deleteDirectory | public static void deleteDirectory(File dir) throws IOException(Code) | | Delete the entire directory dir (if exists)
Parameters: dir - the directory throws: IOException - if dir is not a directory or if any I/O error occours |
getDirectories | public static Vector getDirectories(String dir) throws IOException(Code) | | Return the directories list of the directory dir
Parameters: dir - the directory file a Vector of directory (as File) throws: IOException - if any I/O exception eccours |
getDirectoryNames | public static Vector getDirectoryNames(String dir) throws IOException(Code) | | Return the directories names list of the directory dir
Parameters: dir - the directory name a Vector of directory names (as String) without path throws: IOException - if any I/O exception eccours |
getFileNames | public static Vector getFileNames(String dir) throws IOException(Code) | | Return the filenames list of the directory dir
Parameters: dir - the directory name a Vector of file names (as String) without path throws: IOException - if any I/O exception eccours |
getFileNames | public static Vector getFileNames(String dir, boolean includeDirectory) throws IOException(Code) | | Return the filename list of the directory dir
Parameters: dir - the directory name Parameters: includeDirectory - if true include subdirectories names un the return list a Vector of file names and directories (as String) without path throws: IOException - if any I/O exception eccours |
getFiles | public static Vector getFiles(String dir) throws IOException(Code) | | Return the files list of the directory dir
Parameters: dir - the directory name a Vector of files (as File) excluded subdirectories throws: IOException - if any I/O exception eccours |
getFiles | public static Vector getFiles(String dir, boolean includeDirectory) throws IOException(Code) | | Return the file list of the directory dir
Parameters: dir - the directory name Parameters: includeDirectory - if true include subdirectories names un the return list a Vector of files (as File) throws: IOException - if any I/O exception eccours |
getFiles | public static Vector getFiles(String dir, boolean files, boolean includeDir, boolean name) throws IOException(Code) | | Return the list of files and/or subdirectories of directory dir.
It can return a Vector of names (java.lang.String) or a Vector of files (java.io.File) depending of names parameter;
it can include in the returned Vector:
- files of directory dir (if files parameter is true)
- subdirectories of directory dir (if includeDir parameter is true)
- both files and subdirectories of directory dir (if files and includeDir parameters are both true)
- nothing (if files and includeDir parameters are both false)
Parameters: dir - the directory name Parameters: files - if true the returned vector will contains also files directory dir Parameters: includeDir - if true the returned vector will contains also sub directories of directory dir Parameters: name - if true the returned vector will contains instances of java.io.File class,otherwise it will contains instances of filname without path (as java.lang.String) a Vector of java.io.File or java.lang.String depending of name parameter throws: IOException - |
saveFile | public static void saveFile(String file, byte[] bytes) throws java.io.IOException(Code) | | Create the file file containg bytes
Parameters: file - the file to save Parameters: bytes - the content of the file throws: java.io.IOException - if any Exception occurs |
saveFile | public static void saveFile(File file, byte[] bytes) throws java.io.IOException(Code) | | Create the file file containg bytes
Parameters: file - the file to save Parameters: bytes - the content of the file throws: java.io.IOException - if any Exception occurs |
|
|