Package org.apache.aries.util.io
Class IOUtils
- java.lang.Object
-
- org.apache.aries.util.io.IOUtils
-
public class IOUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description IOUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclose(Closeable c)Close some xStream for good :)static voidclose(ZipFile file)A special version of close() for ZipFiles, which don't implement Closeable.static voidcopy(InputStream in, OutputStream out)Copy an InputStream to an OutputStream and close the InputStream afterwards.static voidcopyAndDoNotCloseInputStream(InputStream in, OutputStream out)Copy an InputStream to an OutputStream and do not close the InputStream afterwards.static booleandeleteRecursive(File root)Do rm -rfstatic OutputStreamgetOutputStream(File outputDir, String relativePath)static voidjarUp(File rootDir, File targetFile, Manifest manifest)Jar up all the contents of rootDir (recursively) into targetFile and add the manifeststatic booleanunpackZip(IFile zip, File outputDir)Unpack the zip file into the outputDirstatic voidwriteOut(File outputDir, String relativePath, InputStream content)Write the given InputStream to a file given by a root directory (outputDir) and a relative directory.static voidwriteOutAndDontCloseInputStream(File outputDir, String relativePath, InputStream content)Write the given InputStream to a file given by a root directory (outputDir) and a relative directory.static voidzipUp(File rootDir, File targetFile)Zip up all contents of rootDir (recursively) into targetFilestatic voidzipUp(File rootDir, OutputStream targetStream)Zip up all contents of rootDir (recursively) into targetStream
-
-
-
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.
-
-