public class IOUtils extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
EOF |
Constructor and Description |
---|
IOUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
absoluteFilePath(java.io.File path,
java.io.File baseDirectory)
Returns an absolute version of
path . |
static void |
copy(java.io.File src,
java.io.File dest)
Copies a file.
|
static void |
copy(java.io.File src,
java.io.File dest,
IOProgressListener progressListener)
Copies a file.
|
static void |
copy(java.io.InputStream in,
java.io.OutputStream out)
Copies data from an
InputStream to an OutputStream . |
static void |
copy(java.io.InputStream in,
java.io.OutputStream out,
boolean close)
Copies data from an
InputStream to an OutputStream . |
static void |
copy(java.io.InputStream in,
java.io.OutputStream out,
boolean close,
IOProgressListener progressListener)
Copies data from an
InputStream to an OutputStream . |
static void |
copy(java.io.InputStream in,
java.io.OutputStream out,
IOProgressListener progressListener)
Copies data from an
InputStream to an OutputStream . |
static void |
copyFromResource(java.lang.String path,
java.io.OutputStream out)
Copies data from an
InputStream to a OutputStream . |
static void |
copyFromResource(java.lang.String path,
java.io.OutputStream out,
IOProgressListener progressListener)
Copies data from an
InputStream to a OutputStream . |
static long |
dirSize(java.util.zip.ZipFile file,
java.lang.String path)
Calculates the overall uncompressed size of all files included in the specified directory of
an archive.
|
static void |
extractDir(java.util.zip.ZipFile file,
java.lang.String sourcePath,
java.lang.String destPath)
Extracts the contents of a directory from an archive (e.g.
|
static void |
extractDir(java.util.zip.ZipFile file,
java.lang.String sourcePath,
java.lang.String destPath,
IOProgressListener progressListener)
Extracts the contents of a directory from an archive (e.g.
|
static void |
extractFile(java.util.zip.ZipFile file,
java.lang.String path,
java.io.File dest)
Extracts a file from an archive (e.g.
|
static void |
extractFile(java.util.zip.ZipFile file,
java.lang.String path,
java.io.File dest,
IOProgressListener progressListener)
Extracts a file from an archive (e.g.
|
static void |
extractFile(java.util.zip.ZipFile file,
java.lang.String path,
java.io.OutputStream out)
Extracts a file from an archive (e.g.
|
static void |
extractFile(java.util.zip.ZipFile file,
java.lang.String path,
java.io.OutputStream out,
IOProgressListener progressListener)
Extracts a file from an archive (e.g.
|
static java.lang.String |
getClassDir(java.lang.Class<?> c) |
static java.lang.String |
getClassLocation(java.lang.Class<?> c)
Returns either the path to the class file of the specified class without the package path or
the path top the archive file that contains it (e.g.
|
public static final int EOF
public IOUtils()
public static java.lang.String getClassLocation(java.lang.Class<?> c)
c
- the class that is contained in the returned JAR-filepublic static java.lang.String getClassDir(java.lang.Class<?> c)
public static java.lang.String absoluteFilePath(java.io.File path, java.io.File baseDirectory)
path
.
If path
is already absolute it will be returned directly. Otherwise it will be considered as being relative to baseDirectory
.
path
- the path to the file or directory to be referencedbaseDirectory
- the directory used to create a absolute path if path
is a relative path.String
java.lang.IllegalArgumentException
- if baseDirectory
is not absolutepublic static void copy(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
InputStream
to an OutputStream
.in
- the stream to read fromout
- the stream to write tojava.io.IOException
- if an I/O error occurspublic static void copy(java.io.InputStream in, java.io.OutputStream out, boolean close) throws java.io.IOException
InputStream
to an OutputStream
.in
- the stream to read fromout
- the stream to write toclose
- defines whether the streams shall be closed after the input stream endedjava.io.IOException
- if an I/O error occurspublic static void copy(java.io.InputStream in, java.io.OutputStream out, IOProgressListener progressListener) throws java.io.IOException
InputStream
to an OutputStream
.in
- the stream to read fromout
- the stream to write toprogressListener
- the progress listener which is informed about the ongoing progressjava.io.IOException
- if an I/O error occurspublic static void copy(java.io.InputStream in, java.io.OutputStream out, boolean close, IOProgressListener progressListener) throws java.io.IOException
InputStream
to an OutputStream
.in
- the stream to read fromout
- the stream to write toclose
- defines whether the streams shall be closed after the input stream ended.progressListener
- the progress listener which is informed about the ongoing progressjava.io.IOException
- if an I/O error occurspublic static void copy(java.io.File src, java.io.File dest, IOProgressListener progressListener) throws java.io.IOException
src
- the source filedest
- the destination fileprogressListener
- the progress listener which is informed about the ongoing progressjava.io.IOException
- if an I/O error occurspublic static void copy(java.io.File src, java.io.File dest) throws java.io.IOException
src
- the source filedest
- the destination filejava.io.IOException
- if an I/O error occurspublic static void copyFromResource(java.lang.String path, java.io.OutputStream out) throws java.io.IOException
InputStream
to a OutputStream
.path
- the path to the resourceout
- the stream to write tojava.io.IOException
- if an I/O error occurspublic static void copyFromResource(java.lang.String path, java.io.OutputStream out, IOProgressListener progressListener) throws java.io.IOException
InputStream
to a OutputStream
.path
- the path to the resourceout
- the stream to write toprogressListener
- the progress listener which is informed about the ongoing progressjava.io.IOException
- if an I/O error occurspublic static void extractFile(java.util.zip.ZipFile file, java.lang.String path, java.io.OutputStream out, IOProgressListener progressListener) throws java.io.IOException
file
- the source archive filepath
- the path of the file to extract inside the archiveout
- the output stream to write the contents of the file toprogressListener
- the progress listener which is informed about the ongoing progressjava.io.IOException
- if an I/O error occurspublic static void extractFile(java.util.zip.ZipFile file, java.lang.String path, java.io.OutputStream out) throws java.io.IOException
file
- the source archive filepath
- the path of the file to extract inside the archiveout
- the output stream to write the contents of the file tojava.io.IOException
- if an I/O error occurspublic static void extractFile(java.util.zip.ZipFile file, java.lang.String path, java.io.File dest, IOProgressListener progressListener) throws java.io.IOException
file
- the source archive filepath
- the path of the file to extract inside the archivedest
- the destination fileprogressListener
- the progress listener which is informed about the ongoing progressjava.io.IOException
- if an I/O error occurspublic static void extractFile(java.util.zip.ZipFile file, java.lang.String path, java.io.File dest) throws java.io.IOException
file
- the source archive filepath
- the path of the file to extract inside the archivedest
- the destination filejava.io.IOException
- if an I/O error occurspublic static void extractDir(java.util.zip.ZipFile file, java.lang.String sourcePath, java.lang.String destPath, IOProgressListener progressListener) throws java.io.IOException
file
- the source archive filesourcePath
- the path of the source directory inside the archive (must not start with
a "/")destPath
- the path of the destination directory where the extracted files should be
storedprogressListener
- the progress listener which is informed about the ongoing progressjava.io.IOException
- if an I/O error occurspublic static void extractDir(java.util.zip.ZipFile file, java.lang.String sourcePath, java.lang.String destPath) throws java.io.IOException
file
- the source archive filesourcePath
- the path of the source directory inside the archive (must not start with
a "/")destPath
- the path of the destination directory where the extracted files should be
storedjava.io.IOException
- if an I/O error occurspublic static long dirSize(java.util.zip.ZipFile file, java.lang.String path)
file
- the source archive filepath
- the path of the source directory inside the archive (must not start with
a "/")