org.apache.aries.util.io
Class IOUtils

java.lang.Object
  extended by org.apache.aries.util.io.IOUtils

public class IOUtils
extends Object


Constructor Summary
IOUtils()
           
 
Method Summary
static void close(Closeable c)
          Close some xStream for good :)
static void close(ZipFile file)
          A special version of close() for ZipFiles, which don't implement Closeable.
static void copy(InputStream in, OutputStream out)
          Copy an InputStream to an OutputStream and close the InputStream afterwards.
static void copyAndDoNotCloseInputStream(InputStream in, OutputStream out)
          Copy an InputStream to an OutputStream and do not close the InputStream afterwards.
static boolean deleteRecursive(File root)
          Do rm -rf
static OutputStream getOutputStream(File outputDir, String relativePath)
           
static void jarUp(File rootDir, File targetFile, Manifest manifest)
          Jar up all the contents of rootDir (recursively) into targetFile and add the manifest
static boolean unpackZip(IFile zip, File outputDir)
          Unpack the zip file into the outputDir
static void writeOut(File outputDir, String relativePath, InputStream content)
          Write the given InputStream to a file given by a root directory (outputDir) and a relative directory.
static void writeOutAndDontCloseInputStream(File outputDir, String relativePath, InputStream content)
          Write the given InputStream to a file given by a root directory (outputDir) and a relative directory.
static void zipUp(File rootDir, File targetFile)
          Zip up all contents of rootDir (recursively) into targetFile
static void zipUp(File rootDir, OutputStream targetStream)
          Zip up all contents of rootDir (recursively) into targetStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOUtils

public IOUtils()
Method Detail

copy

public static void copy(InputStream in,
                        OutputStream out)
                 throws IOException
Copy an InputStream to an OutputStream and close the InputStream afterwards.

Throws:
IOException

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

getOutputStream

public static OutputStream getOutputStream(File outputDir,
                                           String relativePath)
                                    throws IOException
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,
                         OutputStream targetStream)
                  throws IOException
Zip up all contents of rootDir (recursively) into targetStream

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.


Copyright © 2009-2012 The Apache Software Foundation. All Rights Reserved.