org.hd.d.pg2k.svrCore
Class DefInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by java.util.zip.InflaterInputStream
              extended by org.hd.d.pg2k.svrCore.DefInputStream
All Implemented Interfaces:
java.io.Closeable

public final class DefInputStream
extends java.util.zip.InflaterInputStream

Like GZIPInputStream but no GZIP or ZLIB header or checksum. This is meant to give maximum compression and assumes error checking/recovery is done elsewhere.


Field Summary
private  boolean closed
          Is the stream already closed?
private  boolean eos
          Indicates end of input stream.
 
Fields inherited from class java.util.zip.InflaterInputStream
buf, inf, len
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
DefInputStream(java.io.InputStream in)
          Creates a new input stream with a default buffer size.
DefInputStream(java.io.InputStream in, boolean hasDummyTrailingByte)
          Creates a new input stream with the specified buffer size.
 
Method Summary
 void close()
          Closes the input stream and releases non-Java resources.
private  void ensureOpen()
          Check to make sure that this stream has not been closed.
 int read(byte[] buf, int off, int len)
          Reads uncompressed data into an array of bytes.
 
Methods inherited from class java.util.zip.InflaterInputStream
available, fill, mark, markSupported, read, reset, skip
 
Methods inherited from class java.io.FilterInputStream
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eos

private boolean eos
Indicates end of input stream.


closed

private boolean closed
Is the stream already closed?

Constructor Detail

DefInputStream

public DefInputStream(java.io.InputStream in,
                      boolean hasDummyTrailingByte)
               throws java.io.IOException
Creates a new input stream with the specified buffer size. In cases where we know that the input stream has one or more trailing bytes that we don't care about then the hasDummyTrailingData arg can be true to save us having to wrap the input stream.

Parameters:
in - the input stream
hasDummyTrailingByte - if true then the input stream has one or more bytes of trailing data that ZLIB can eat harmlessly
Throws:
java.io.IOException - if an I/O error has occurred

DefInputStream

public DefInputStream(java.io.InputStream in)
               throws java.io.IOException
Creates a new input stream with a default buffer size.

Parameters:
in - the input stream
Throws:
java.io.IOException - if an I/O error has occurred
Method Detail

ensureOpen

private void ensureOpen()
                 throws java.io.IOException
Check to make sure that this stream has not been closed.

Throws:
java.io.IOException

read

public int read(byte[] buf,
                int off,
                int len)
         throws java.io.IOException
Reads uncompressed data into an array of bytes. Blocks until enough input is available for decompression.

Overrides:
read in class java.util.zip.InflaterInputStream
Returns:
the actual number of bytes read, or -1 if the end of the compressed input stream is reached
Throws:
java.io.IOException - if an I/O error has occurred or the compressed input data is corrupt

close

public void close()
           throws java.io.IOException
Closes the input stream and releases non-Java resources.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.util.zip.InflaterInputStream
Throws:
java.io.IOException - if an I/O error has occurred

DHD Multimedia Gallery V1.50.55

Copyright (c) 1996-2008, Damon Hart-Davis. All rights reserved.