Package io.hawt.util

Class Files


  • public class Files
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Files()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void assertDirectoryExists​(java.io.File file)
      Throws an exception if the given file does not exist
      static void assertExists​(java.io.File file)
      Throws an exception if the given file or directory does not exist
      static void assertFileExists​(java.io.File file)
      Throws an exception if the given file does not exist
      static void copy​(java.io.File source, java.io.File target)
      Copy the source File to the target File.
      static java.lang.String getMimeType​(java.io.File file)  
      static java.lang.String getRelativePath​(java.io.File rootDir, java.io.File file)  
      static byte[] readBytes​(java.io.File file)
      Reads a File and returns the data as a byte array
      static int recursiveDelete​(java.io.File file)
      Recursively deletes the given file whether it's a file or directory returning the number of files deleted
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Files

        public Files()
    • Method Detail

      • copy

        public static void copy​(java.io.File source,
                                java.io.File target)
                         throws java.io.IOException
        Copy the source File to the target File.
        Throws:
        java.io.IOException
      • recursiveDelete

        public static int recursiveDelete​(java.io.File file)
        Recursively deletes the given file whether it's a file or directory returning the number of files deleted
      • getRelativePath

        public static java.lang.String getRelativePath​(java.io.File rootDir,
                                                       java.io.File file)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • readBytes

        public static byte[] readBytes​(java.io.File file)
                                throws java.io.IOException
        Reads a File and returns the data as a byte array
        Throws:
        java.io.IOException
      • getMimeType

        public static java.lang.String getMimeType​(java.io.File file)
      • assertExists

        public static void assertExists​(java.io.File file)
        Throws an exception if the given file or directory does not exist
      • assertFileExists

        public static void assertFileExists​(java.io.File file)
        Throws an exception if the given file does not exist
      • assertDirectoryExists

        public static void assertDirectoryExists​(java.io.File file)
        Throws an exception if the given file does not exist