| java.lang.Object org.java.plugin.util.IoUtil
IoUtil | final public class IoUtil (Code) | | Input/Output, File and URL/URI related utilities.
version: $Id: IoUtil.java,v 1.9 2007/04/17 17:39:52 ddimon Exp $ |
Method Summary | |
public static boolean | compareFileDates(Date date1, Date date2) For some reason modification milliseconds for some files are unstable,
use this function to compare file dates ignoring milliseconds. | public static boolean | compareFiles(File file1, File file2) Compares two files for directories/files synchronization purposes. | public static void | copyFile(File src, File dest) Copies one file, existing file will be overridden. | public static void | copyFolder(File src, File dest) | public static void | copyFolder(File src, File dest, boolean recursive) | public static void | copyFolder(File src, File dest, boolean recursive, boolean onlyNew) Copies folder. | public static void | copyFolder(File src, File dest, boolean recursive, boolean onlyNew, FileFilter filter) Copies folder. | public static void | copyStream(InputStream in, OutputStream out, int bufferSize) Copies streams. | public static boolean | emptyFolder(File folder) Recursively deletes whole content of the given folder. | public static URL | file2url(File file) Utility method to convert a
File object to a local URL. | public static InputStream | getResourceInputStream(URL url) Opens input stream for given resource. | public static boolean | isResourceExists(URL url) Checks if resource exist and can be opened. | public static void | synchronizeFolders(File src, File dest) Performs one-way directories synchronization comparing files only,
not folders. | public static void | synchronizeFolders(File src, File dest, FileFilter filter) Performs one-way directories synchronization comparing files only,
not folders. | public static File | url2file(URL url) Utility method to convert local URL to a
File object. |
compareFileDates | public static boolean compareFileDates(Date date1, Date date2)(Code) | | For some reason modification milliseconds for some files are unstable,
use this function to compare file dates ignoring milliseconds.
Parameters: date1 - first file modification date Parameters: date2 - second file modification date true if files modification dates are equal ignoringmilliseconds |
compareFiles | public static boolean compareFiles(File file1, File file2)(Code) | | Compares two files for directories/files synchronization purposes.
Parameters: file1 - one file to compare Parameters: file2 - another file to compare true if file names are equal (case sensitive), fileshave equal lengths and modification dates (milliseconds ignored) See Also: IoUtil.synchronizeFolders(File,File) See Also: IoUtil.compareFileDates(Date,Date) |
copyFile | public static void copyFile(File src, File dest) throws IOException(Code) | | Copies one file, existing file will be overridden.
Parameters: src - source file to copy FROM Parameters: dest - destination file to copy TO throws: IOException - if any I/O error has occurred |
copyFolder | public static void copyFolder(File src, File dest) throws IOException(Code) | | Copies folder recursively, existing files will be overridden
Parameters: src - source folder Parameters: dest - target folder throws: IOException - if any I/O error has occurred |
copyFolder | public static void copyFolder(File src, File dest, boolean recursive) throws IOException(Code) | | Copies folder, existing files will be overridden
Parameters: src - source folder Parameters: dest - target folder Parameters: recursive - if true , processes folder recursively throws: IOException - if any I/O error has occurred |
copyFolder | public static void copyFolder(File src, File dest, boolean recursive, boolean onlyNew) throws IOException(Code) | | Copies folder.
Parameters: src - source folder Parameters: dest - target folder Parameters: recursive - if true , processes folder recursively Parameters: onlyNew - if true , target file will be overridden if itis older than source file only throws: IOException - if any I/O error has occurred |
copyFolder | public static void copyFolder(File src, File dest, boolean recursive, boolean onlyNew, FileFilter filter) throws IOException(Code) | | Copies folder.
Parameters: src - source folder Parameters: dest - target folder Parameters: recursive - if true , processes folder recursively Parameters: onlyNew - if true , target file will be overridden if itis older than source file only Parameters: filter - file filter, optional, if null all files willbe copied throws: IOException - if any I/O error has occurred |
copyStream | public static void copyStream(InputStream in, OutputStream out, int bufferSize) throws IOException(Code) | | Copies streams.
Parameters: in - source stream Parameters: out - destination stream Parameters: bufferSize - buffer size to use throws: IOException - if any I/O error has occurred |
emptyFolder | public static boolean emptyFolder(File folder)(Code) | | Recursively deletes whole content of the given folder.
Parameters: folder - folder to be emptied true if given folder becomes empty or not exists |
getResourceInputStream | public static InputStream getResourceInputStream(URL url) throws IOException(Code) | | Opens input stream for given resource. This method behaves differently
for different URL types:
- for local files it returns buffered file input stream;
- for local JAR files it reads resource content into memory
buffer and returns byte array input stream that wraps those
buffer (this prevents locking JAR file);
- for common URL's this method simply opens stream to that URL
using standard URL API.
It is not recommended to use this method for big resources within JAR
files.
Parameters: url - resource URL input stream for given resource throws: IOException - if any I/O error has occurred |
isResourceExists | public static boolean isResourceExists(URL url)(Code) | | Checks if resource exist and can be opened.
Parameters: url - absolute URL which points to a resource to be checked true if given URL points to an existing resource |
synchronizeFolders | public static void synchronizeFolders(File src, File dest, FileFilter filter) throws IOException(Code) | | Performs one-way directories synchronization comparing files only,
not folders.
Parameters: src - source folder Parameters: dest - target folder Parameters: filter - file filter, optional, if null all files willbe included into synchronization process throws: IOException - if any I/O error has occurred See Also: IoUtil.compareFiles(File,File) |
url2file | public static File url2file(URL url)(Code) | | Utility method to convert local URL to a
File object.
Parameters: url - an URL file object for given URL or null if URL is notlocal |
|
|