Class IOUtils


  • public class IOUtils
    extends Object
    • Constructor Detail

      • IOUtils

        public IOUtils()
    • Method Detail

      • copyAndDoNotCloseInputStream

        public static void copyAndDoNotCloseInputStream​(InputStream in,
                                                        OutputStream out)
                                                 throws IOException
        Copy an InputStream to an OutputStream and do not close the InputStream afterwards.
        Throws:
        IOException
      • close

        public static void close​(Closeable c)
        Close some xStream for good :)
      • close

        public static void close​(ZipFile file)
                          throws IOException
        A special version of close() for ZipFiles, which don't implement Closeable.
        Parameters:
        file - the file to close. ZipFiles seem prone to file locking problems on Windows, so to aid diagnostics we throw, not swallow, any exceptions.
        Throws:
        IOException
      • writeOut

        public static void writeOut​(File outputDir,
                                    String relativePath,
                                    InputStream content)
                             throws IOException
        Write the given InputStream to a file given by a root directory (outputDir) and a relative directory. Necessary subdirectories will be created. This method will close the supplied InputStream.
        Throws:
        IOException
      • writeOutAndDontCloseInputStream

        public static void writeOutAndDontCloseInputStream​(File outputDir,
                                                           String relativePath,
                                                           InputStream content)
                                                    throws IOException
        Write the given InputStream to a file given by a root directory (outputDir) and a relative directory. Necessary subdirectories will be created. This method will not close the supplied InputStream.
        Throws:
        IOException
      • zipUp

        public static void zipUp​(File rootDir,
                                 File targetFile)
                          throws IOException
        Zip up all contents of rootDir (recursively) into targetFile
        Throws:
        IOException
      • jarUp

        public static void jarUp​(File rootDir,
                                 File targetFile,
                                 Manifest manifest)
                          throws IOException
        Jar up all the contents of rootDir (recursively) into targetFile and add the manifest
        Throws:
        IOException
      • deleteRecursive

        public static boolean deleteRecursive​(File root)
        Do rm -rf
      • unpackZip

        public static boolean unpackZip​(IFile zip,
                                        File outputDir)
                                 throws IOException
        Unpack the zip file into the outputDir
        Parameters:
        zip -
        outputDir -
        Returns:
        true if the zip was expanded, false if the zip was found not to be a zip
        Throws:
        IOException - when there are unexpected issues handling the zip files.