Package org.apache.aries.util.io
Class IOUtils
- java.lang.Object
-
- org.apache.aries.util.io.IOUtils
-
public class IOUtils extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description IOUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclose(java.io.Closeable c)Close some xStream for good :)static voidclose(java.util.zip.ZipFile file)A special version of close() for ZipFiles, which don't implement Closeable.static voidcopy(java.io.InputStream in, java.io.OutputStream out)Copy an InputStream to an OutputStream and close the InputStream afterwards.static voidcopyAndDoNotCloseInputStream(java.io.InputStream in, java.io.OutputStream out)Copy an InputStream to an OutputStream and do not close the InputStream afterwards.static booleandeleteRecursive(java.io.File root)Do rm -rfstatic java.io.OutputStreamgetOutputStream(java.io.File outputDir, java.lang.String relativePath)static voidjarUp(java.io.File rootDir, java.io.File targetFile, java.util.jar.Manifest manifest)Jar up all the contents of rootDir (recursively) into targetFile and add the manifeststatic booleanunpackZip(IFile zip, java.io.File outputDir)Unpack the zip file into the outputDirstatic voidwriteOut(java.io.File outputDir, java.lang.String relativePath, java.io.InputStream content)Write the given InputStream to a file given by a root directory (outputDir) and a relative directory.static voidwriteOutAndDontCloseInputStream(java.io.File outputDir, java.lang.String relativePath, java.io.InputStream content)Write the given InputStream to a file given by a root directory (outputDir) and a relative directory.static voidzipUp(java.io.File rootDir, java.io.File targetFile)Zip up all contents of rootDir (recursively) into targetFilestatic voidzipUp(java.io.File rootDir, java.io.OutputStream targetStream)Zip up all contents of rootDir (recursively) into targetStream
-
-
-
Method Detail
-
copy
public static void copy(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOExceptionCopy an InputStream to an OutputStream and close the InputStream afterwards.- Throws:
java.io.IOException
-
copyAndDoNotCloseInputStream
public static void copyAndDoNotCloseInputStream(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOExceptionCopy an InputStream to an OutputStream and do not close the InputStream afterwards.- Throws:
java.io.IOException
-
close
public static void close(java.io.Closeable c)
Close some xStream for good :)
-
close
public static void close(java.util.zip.ZipFile file) throws java.io.IOExceptionA 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:
java.io.IOException
-
getOutputStream
public static java.io.OutputStream getOutputStream(java.io.File outputDir, java.lang.String relativePath) throws java.io.IOException- Throws:
java.io.IOException
-
writeOut
public static void writeOut(java.io.File outputDir, java.lang.String relativePath, java.io.InputStream content) throws java.io.IOExceptionWrite 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:
java.io.IOException
-
writeOutAndDontCloseInputStream
public static void writeOutAndDontCloseInputStream(java.io.File outputDir, java.lang.String relativePath, java.io.InputStream content) throws java.io.IOExceptionWrite 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:
java.io.IOException
-
zipUp
public static void zipUp(java.io.File rootDir, java.io.OutputStream targetStream) throws java.io.IOExceptionZip up all contents of rootDir (recursively) into targetStream- Throws:
java.io.IOException
-
zipUp
public static void zipUp(java.io.File rootDir, java.io.File targetFile) throws java.io.IOExceptionZip up all contents of rootDir (recursively) into targetFile- Throws:
java.io.IOException
-
jarUp
public static void jarUp(java.io.File rootDir, java.io.File targetFile, java.util.jar.Manifest manifest) throws java.io.IOExceptionJar up all the contents of rootDir (recursively) into targetFile and add the manifest- Throws:
java.io.IOException
-
deleteRecursive
public static boolean deleteRecursive(java.io.File root)
Do rm -rf
-
unpackZip
public static boolean unpackZip(IFile zip, java.io.File outputDir) throws java.io.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:
java.io.IOException- when there are unexpected issues handling the zip files.
-
-