Class FileUtils


  • public final class FileUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void copy​(java.io.InputStream in, java.io.OutputStream out)
      Basic stream copy, the streams are already open and stay open afterward.
      static java.io.File createTempDirectory​(java.lang.String prefix, java.io.File parent)
      Create a temporary directory which should be deleted on application close.
      static java.lang.String toFilename​(java.lang.String name, java.lang.String extension)  
      static java.lang.String toFilename​(java.lang.String prefix, java.lang.String suffix, java.lang.String extension)
      Build a file name.
      static void unzipFile​(java.io.File file)
      Unzip the specified zip file into a directory of the same name as the zip file minus the suffix within the same parent directory.
      static void unzipFile​(java.io.File file, java.io.File destinationDirectory)
      Unzip the specified zip file into the specified destination.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • copy

        public static final void copy​(java.io.InputStream in,
                                      java.io.OutputStream out)
                               throws java.io.IOException
        Basic stream copy, the streams are already open and stay open afterward.
        Parameters:
        in - input stream
        out - output stream
        Throws:
        java.io.IOException - if there was a problem with the copy
      • createTempDirectory

        public static java.io.File createTempDirectory​(java.lang.String prefix,
                                                       java.io.File parent)
                                                throws java.io.IOException
        Create a temporary directory which should be deleted on application close.
        Parameters:
        prefix - a prefix for the new directory name
        parent - a directory to put the new directory into
        Returns:
        the temporary directory, to be deleted on shutdown
        Throws:
        java.io.IOException - if something goes wrong
      • toFilename

        public static java.lang.String toFilename​(java.lang.String name,
                                                  java.lang.String extension)
      • toFilename

        public static java.lang.String toFilename​(java.lang.String prefix,
                                                  java.lang.String suffix,
                                                  java.lang.String extension)
        Build a file name. Convert non-letters or digits to underscore.
        Parameters:
        prefix - the prefix of the file
        suffix - the suffix
        extension - the file extension
        Returns:
        the combined file name
      • unzipFile

        public static void unzipFile​(java.io.File file)
                              throws java.io.IOException
        Unzip the specified zip file into a directory of the same name as the zip file minus the suffix within the same parent directory.
        Parameters:
        file - .zip file
        Throws:
        java.io.IOException
        Since:
        1.12
      • unzipFile

        public static void unzipFile​(java.io.File file,
                                     java.io.File destinationDirectory)
                              throws java.io.IOException
        Unzip the specified zip file into the specified destination.
        Parameters:
        file - .zip file
        destinationDirectory - Destination directory
        Throws:
        java.io.IOException
        Since:
        1.12