net.sf.sevenzipjbinding.impl
Class InputStreamSequentialInStream

java.lang.Object
  extended by net.sf.sevenzipjbinding.impl.InputStreamSequentialInStream
All Implemented Interfaces:
java.io.Closeable, ISequentialInStream

public class InputStreamSequentialInStream
extends java.lang.Object
implements ISequentialInStream

Input stream based implementation of ISequentialInStream.

Since:
9.20-2.00
Author:
Boris Brodski

Constructor Summary
InputStreamSequentialInStream(java.io.InputStream inputStream)
          Create new input stream based implementation of ISequentialInStream.
 
Method Summary
 void close()
           
 java.io.InputStream getInputStream()
          Returns base input stream
 int read(byte[] data)
          Reads at least 1 and maximum data.length bytes from the in-stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputStreamSequentialInStream

public InputStreamSequentialInStream(java.io.InputStream inputStream)
Create new input stream based implementation of ISequentialInStream.

Parameters:
inputStream - base input stream.
Method Detail

read

public int read(byte[] data)
         throws SevenZipException
Reads at least 1 and maximum data.length bytes from the in-stream. If data.length == 0 0 should be returned. If data.length != 0, then return value 0 indicates end-of-stream (EOF). This means no more bytes can be read from the stream.
This function is allowed to read less than number of remaining bytes in stream and less then data.length. You must call read() function in loop, if you need exact amount of data.

Note: depending on the archive format and the data size this method may be called from different threads. Synchronized implementation may be required.

Specified by:
read in interface ISequentialInStream
Parameters:
data - buffer to get read data
Returns:
amount of bytes written in the data array. 0 - represents end of stream.
Throws:
SevenZipException - in error case. If this method ends with an exception, the current operation will be reported to 7-Zip as failed. There are no guarantee, that there are no further call back methods will get called. The first and last thrown exceptions will be saved and thrown later on from the originally called method such as ISevenZipInArchive.extract() or SevenZip.openInArchive(). Up to four exceptions depending on the situation can be saved for further analysis. See SevenZipException and SevenZipException.printStackTraceExtended() for details.

getInputStream

public java.io.InputStream getInputStream()
Returns base input stream

Returns:
input stream

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Throws:
java.io.IOException