public class CompressionManager
extends java.lang.Object
To avoid direct dependencies to compression libraries, the
ServiceLoader
concept is used. This allows additional compression
types to be added without changing any SimLib class. The SimLib supports
uncompressed files as well as the compressed files of the types gzip, xz,
lzma and bzip2.
To implement additional compression types, you have to
CompressionProvider
ServiceLoader
and
http://ant.apache.org/manual/Tasks/jar.html
Constructor and Description |
---|
CompressionManager() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getFilenameWithExtension(java.lang.String fileName,
CompressionType compressionType) |
static java.io.InputStream |
getInputStream(java.io.File file)
Opens the given file for reading.
|
static java.io.OutputStream |
getOutPutStream(java.io.File file)
Opens the given file for writing.
|
static java.io.OutputStream |
getOutputStream(java.io.File file,
CompressionType compressionType)
Opens the given file for writing.
|
public static java.io.InputStream getInputStream(java.io.File file) throws java.io.FileNotFoundException
file
- the file to open, with extension as it is on the diskjava.io.FileNotFoundException
- when the file is not readablepublic static java.io.OutputStream getOutputStream(java.io.File file, CompressionType compressionType) throws java.io.FileNotFoundException
getFilenameWithExtension(String, CompressionType)
.file
- the file to open, with extension as it shall be createdcompressionType
- the type of file compression which shall be usedjava.io.FileNotFoundException
- when the file cannot be createdpublic static java.io.OutputStream getOutPutStream(java.io.File file) throws java.io.FileNotFoundException
CompressionType
then a file with corresponding compression shall be created.
If the extension could not be recognized then a regular file of
given name and extension shall be created.file
- the file to open, with extension as it shall be createdjava.io.FileNotFoundException
- when the file cannot be createdpublic static java.lang.String getFilenameWithExtension(java.lang.String fileName, CompressionType compressionType)