Class FileUtils


  • public final class FileUtils
    extends Object
    • Method Detail

      • copy

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

        public static File createTempDirectory​(String prefix,
                                               File parent)
                                        throws 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:
        IOException - if something goes wrong
      • toFilename

        public static String toFilename​(String prefix,
                                        String suffix,
                                        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​(File file)
                              throws 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:
        IOException
        Since:
        1.12
      • unzipFile

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