Package com.epimorphics.util
Class FileUtil
- java.lang.Object
-
- com.epimorphics.util.FileUtil
-
public class FileUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description FileUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FileabsoluteFile(File parent, String file)Construct a File reference for "file".static FileabsoluteFile(String parent, String file)Construct a File reference for "file".static longchecksum(File file)Compute a checksum for a file for use in detecting changes.static longchecksum(String filename)Compute a checksum for a file for use in detecting changes.static longchecksum(URL url)Compute a checksum for a bundle URL for use in detecting changes.static voidcopyDirectory(Path src, Path dest)Copy a directory tree from a source location to a destinationstatic longcopyResource(File src, OutputStream os)Copy a source file to the output stream, byte for byte.static longcopyResource(File src, Writer out)Copy a source file to the output writer, reading the source as UTF-8.static longcopyResource(InputStream is, OutputStream os)Copy a source file to the output stream, byte for byte.static longcopyResource(InputStream is, Writer out)Copy a source file to the output stream, byte for byte.static longcopyResource(Reader in, Writer out)Copy a source reader to the output writer.static voidcopyResource(String src, String dest)Copy a source file to a destination filestatic voiddeleteDirectory(File directory)Remove the directory.static voiddeleteDirectory(String directory)Remove the directory.static FileensureDir(String dir)Ensure the given directory exists and is writable.
-
-
-
Method Detail
-
copyResource
public static long copyResource(File src, Writer out) throws IOException
Copy a source file to the output writer, reading the source as UTF-8. Returns number of chars copied. Leaves output open.- Throws:
IOException
-
copyResource
public static long copyResource(Reader in, Writer out) throws IOException
Copy a source reader to the output writer. Returns number of chars copied. Leaves output open.- Throws:
IOException
-
copyResource
public static long copyResource(File src, OutputStream os) throws IOException
Copy a source file to the output stream, byte for byte. Returns number of bytes copied. Leaves output open.- Throws:
IOException
-
copyResource
public static long copyResource(InputStream is, OutputStream os) throws IOException
Copy a source file to the output stream, byte for byte. Returns number of bytes copied. Leaves output open.- Throws:
IOException
-
copyResource
public static long copyResource(InputStream is, Writer out) throws IOException
Copy a source file to the output stream, byte for byte. Returns number of bytes copied. Leaves output open.- Throws:
IOException
-
copyResource
public static void copyResource(String src, String dest) throws IOException
Copy a source file to a destination file- Throws:
IOException
-
copyDirectory
public static void copyDirectory(Path src, Path dest) throws IOException
Copy a directory tree from a source location to a destination- Throws:
IOException
-
ensureDir
public static File ensureDir(String dir) throws EpiException
Ensure the given directory exists and is writable. Tries to create it if necessary.- Throws:
ModalExeption- if the directory exists but is not accessibleEpiException
-
deleteDirectory
public static void deleteDirectory(String directory)
Remove the directory.
-
deleteDirectory
public static void deleteDirectory(File directory)
Remove the directory.
-
absoluteFile
public static File absoluteFile(String parent, String file)
Construct a File reference for "file". If "file" is absolute then use that, if it is relative then make it relative to the given parent.
-
absoluteFile
public static File absoluteFile(File parent, String file)
Construct a File reference for "file". If "file" is absolute then use that, if it is relative then make it relative to the given parent.
-
checksum
public static long checksum(String filename)
Compute a checksum for a file for use in detecting changes. May not check whole file contents.
-
checksum
public static long checksum(File file)
Compute a checksum for a file for use in detecting changes. May not check whole file contents.
-
checksum
public static long checksum(URL url)
Compute a checksum for a bundle URL for use in detecting changes. May not check whole file contents.
-
-