Package org.biojava.nbio.core.util
Class UncompressInputStream
- java.lang.Object
- 
- java.io.InputStream
- 
- java.io.FilterInputStream
- 
- org.biojava.nbio.core.util.UncompressInputStream
 
 
 
- 
- All Implemented Interfaces:
- Closeable,- AutoCloseable
 
 public class UncompressInputStream extends FilterInputStream This class decompresses an input stream containing data compressed with the unix "compress" utility (LZC, a LZW variant). This code is based heavily on the unlzw.c code in gzip-1.2.4 (written by Peter Jannesen) and the original compress code. This version has been modified from the original 0.3-3 version by the Unidata Program Center (support@xxxxxxxxxxxxxxxx) to make the constructor public and to fix a couple of bugs. Also: - markSupported() returns false - add uncompress() static method- Version:
- 0.3-3 06/05/2001, 0.3-5 2008/01/19, 1.0 2018/01/08
- Author:
- Ronald Tschalar, Unidata Program Center, Richard Holland - making LZW_MAGIC package-visible., Fred Hansen (zweibieren@yahoo.com) Fixed available() and the EOF condition for mainloop. Also added some comments., Fred Hansen (zweibieren@yahoo.com) added uncompress(InputStream,OutputStream) and called it from main(String[]) and uncompress(String, FileOutputStream) normalize indentation rewrite skip method amend logging code in uncompress(String, FileOutputStream)
 
- 
- 
Field Summary- 
Fields inherited from class java.io.FilterInputStreamin
 
- 
 - 
Constructor SummaryConstructors Constructor Description UncompressInputStream(InputStream is)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()static voidmain(String[] args)Reads a file, uncompresses it, and sends the result to stdout.booleanmarkSupported()This stream does not support mark/reset on the stream.intread()intread(byte[] buf, int off, int len)longskip(long num)static longuncompress(InputStream in, OutputStream out)Read an input stream and uncompress it to an output stream.static longuncompress(String fileInName, FileOutputStream out)Read a named file and uncompress it.- 
Methods inherited from class java.io.FilterInputStreamclose, mark, read, reset
 - 
Methods inherited from class java.io.InputStreamnullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
 
- 
 
- 
- 
- 
Constructor Detail- 
UncompressInputStreampublic UncompressInputStream(InputStream is) throws IOException - Parameters:
- is- the input stream to decompress
- Throws:
- IOException- if the header is malformed
 
 
- 
 - 
Method Detail- 
readpublic int read() throws IOException - Overrides:
- readin class- FilterInputStream
- Throws:
- IOException
 
 - 
readpublic int read(byte[] buf, int off, int len) throws IOException - Overrides:
- readin class- FilterInputStream
- Throws:
- IOException
 
 - 
skippublic long skip(long num) throws IOException - Overrides:
- skipin class- FilterInputStream
- Throws:
- IOException
 
 - 
availablepublic int available() throws IOException - Overrides:
- availablein class- FilterInputStream
- Throws:
- IOException
 
 - 
markSupportedpublic boolean markSupported() This stream does not support mark/reset on the stream.- Overrides:
- markSupportedin class- FilterInputStream
- Returns:
- false
 
 - 
uncompresspublic static long uncompress(String fileInName, FileOutputStream out) throws IOException Read a named file and uncompress it.- Parameters:
- fileInName- Name of compressed file.
- out- A destination for the result. It is closed after data is sent.
- Returns:
- number of bytes sent to the output stream,
- Throws:
- IOException- for any error
 
 - 
uncompresspublic static long uncompress(InputStream in, OutputStream out) throws IOException Read an input stream and uncompress it to an output stream.- Parameters:
- in- the incoming InputStream. It is NOT closed.
- out- the destination OutputStream. It is NOT closed.
- Returns:
- number of bytes sent to the output stream
- Throws:
- IOException- for any error
 
 - 
mainpublic static void main(String[] args) throws Exception Reads a file, uncompresses it, and sends the result to stdout. Also writes trivial statistics to stderr.- Parameters:
- args- An array with one String element, the name of the file to read.
- Throws:
- IOException- for any failure
- Exception
 
 
- 
 
-