public final class IOUtils extends Object
Modifier and Type | Method and Description |
---|---|
static Collection<File> |
extract(File baseDir,
InputStream in)
Extract a ZIP archive.
|
static URI |
getRelativePath(URI targetURI,
URI baseURI)
Returns a relative path between basePath and targetPath if possible.
|
static String |
humanReadableByteCount(long bytes,
boolean si)
Get the human readable notation of a size in bytes.
|
static URI |
relativeFileToURI(File file)
Returns a URI for the given file.
|
static boolean |
testStream(URI uri,
boolean allowResource)
Tests whether a InputStream to the given URI can be opened.
|
static void |
zipDirectory(File zipDir,
ZipOutputStream zos)
ZIP a directory with sub-folders and write it to the given output stream.
|
public static boolean testStream(URI uri, boolean allowResource)
uri
- the URI to testallowResource
- allow resolving through Resources
public static Collection<File> extract(File baseDir, InputStream in) throws IOException
baseDir
- the base directory to extract toin
- the input stream of the ZIP archive, which is closed after
extractionIOException
- if an error occurspublic static void zipDirectory(File zipDir, ZipOutputStream zos) throws IOException
zipDir
- the directory to ZIPzos
- the ZIP output streamIOException
- if reading the directory or writing the ZIP stream
failspublic static URI getRelativePath(URI targetURI, URI baseURI)
targetURI
- the target pathbaseURI
- the base pathpublic static URI relativeFileToURI(File file)
File.toURI()
it does not resolve a relative file,
but instead returns a relative URI.file
- the file to transformpublic static String humanReadableByteCount(long bytes, boolean si)
bytes
- the number of bytessi
- if the SI or binary unit should be usedBuild 2013-10-07_11-27-38
Revision 99b27713a799a59a21b0b166eaaea8aaefbf125a