Class FileUtil


  • public class FileUtil
    extends Object
    • Constructor Detail

      • FileUtil

        public FileUtil()
    • 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
      • 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 accessible
        EpiException
      • 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.