Class FileUtils


  • public class FileUtils
    extends Object

    FileUtils: File utilities

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.util.Map<String,​Object> fileEditors  
    • Constructor Summary

      Constructors 
      Constructor Description
      FileUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void closeQuietly​(java.io.InputStream stream)  
      static void closeQuietly​(java.io.OutputStream stream)  
      static void closeQuietly​(java.io.Reader reader)  
      static void copyFile​(java.io.File fromFile, java.io.File toFile)
      Simple file copy routine
      static void copyFile2​(java.io.File fromFile, java.io.File toFile)  
      static boolean deleteDirectory​(java.io.File path)  
      static void deleteFolder​(java.io.File folder)  
      static byte[] fileToByteArray​(java.io.File file)  
      static Object getFileEditor​(String filePath)  
      static String streamNameToValidFilename​(String name)
      Encode a stream name (deal with path elements) to a valid filename.
      static String toValidFilename​(String name)
      Encode a name to a valid filename.
      static void traverseDirectory​(java.io.File dir, IFileProcess fileNotify)
      Traverse a directory recursively calling fileNotify for each file and folder encountered
      static java.io.File versionFile​(java.io.File newFile)
      Rename a file using the file format [original-name]_#[.ext].
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • fileEditors

        protected static java.util.Map<String,​Object> fileEditors
    • Constructor Detail

      • FileUtils

        public FileUtils()
    • Method Detail

      • fileToByteArray

        public static byte[] fileToByteArray​(java.io.File file)
      • streamNameToValidFilename

        public static String streamNameToValidFilename​(String name)
        Encode a stream name (deal with path elements) to a valid filename.
        Parameters:
        name - stream name
        Returns:
        encoded filename
      • toValidFilename

        public static String toValidFilename​(String name)
        Encode a name to a valid filename.
        Parameters:
        name -
        Returns:
        encoded filename
      • copyFile

        public static void copyFile​(java.io.File fromFile,
                                    java.io.File toFile)
        Simple file copy routine
        Parameters:
        fromFile - from file
        toFile - to file
      • copyFile2

        public static void copyFile2​(java.io.File fromFile,
                                     java.io.File toFile)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • closeQuietly

        public static void closeQuietly​(java.io.InputStream stream)
      • closeQuietly

        public static void closeQuietly​(java.io.OutputStream stream)
      • closeQuietly

        public static void closeQuietly​(java.io.Reader reader)
      • deleteDirectory

        public static boolean deleteDirectory​(java.io.File path)
      • versionFile

        public static java.io.File versionFile​(java.io.File newFile)
        Rename a file using the file format [original-name]_#[.ext].
        Parameters:
        newFile - input file
        Returns:
        renamed file
      • traverseDirectory

        public static void traverseDirectory​(java.io.File dir,
                                             IFileProcess fileNotify)
        Traverse a directory recursively calling fileNotify for each file and folder encountered
        Parameters:
        dir - starting directory
        fileNotify - file notify object
      • deleteFolder

        public static void deleteFolder​(java.io.File folder)
      • getFileEditor

        public static Object getFileEditor​(String filePath)