Class FileUtil


  • public abstract class FileUtil
    extends java.lang.Object
    File utilities
    Author:
    Bruno Dillenseger
    • Constructor Summary

      Constructors 
      Constructor Description
      FileUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void copyFromResource​(java.lang.String resource, java.io.File target)
      Creates/overwrites a file copying content from a resource.
      static boolean delete​(java.io.File root)
      Recursively deletes a directory or just a single file.
      • Methods inherited from class java.lang.Object

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

      • FileUtil

        public FileUtil()
    • Method Detail

      • delete

        public static boolean delete​(java.io.File root)
        Recursively deletes a directory or just a single file. Fails as soon as one file can't be deleted.
        Parameters:
        root - the file or directory to delete
        Returns:
        true if the file or directory have been deleted, false if at least one file could not be deleted.
      • copyFromResource

        public static void copyFromResource​(java.lang.String resource,
                                            java.io.File target)
                                     throws java.io.IOException
        Creates/overwrites a file copying content from a resource.
        Parameters:
        resource - the resource file path (to be resolved using this class' class loader)
        target - the file path to create (all directories in the path are created when necessary and possible)
        Throws:
        java.io.IOException - an exception occurred either while trying to get the resource or creating the target file