Package loci.poi.util
Class BlockingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- loci.poi.util.BlockingInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class BlockingInputStream extends InputStream
Implementation of a BlockingInputStream to provide data to RawDataBlock that expects data in 512 byte chunks. Useful to read data from slow (ie, non FileInputStream) sources, for example when reading an OLE2 Document over a network. Possible extentions: add a timeout. Curently a call to read(byte[]) on this class is blocking, so use at your own peril if your underlying stream blocks.- Author:
- Jens Gerhard, aviks - documentation cleanups.
-
-
Field Summary
Fields Modifier and Type Field Description protected InputStream
is
-
Constructor Summary
Constructors Constructor Description BlockingInputStream(InputStream is)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
void
close()
void
mark(int readLimit)
boolean
markSupported()
int
read()
int
read(byte[] bf)
We had to revert to byte per byte reading to keep with slow network connections on one hand, without missing the end-of-file.int
read(byte[] bf, int s, int l)
void
reset()
long
skip(long n)
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Field Detail
-
is
protected InputStream is
-
-
Constructor Detail
-
BlockingInputStream
public BlockingInputStream(InputStream is)
-
-
Method Detail
-
available
public int available() throws IOException
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
mark
public void mark(int readLimit)
- Overrides:
mark
in classInputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classInputStream
-
read
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
public int read(byte[] bf) throws IOException
We had to revert to byte per byte reading to keep with slow network connections on one hand, without missing the end-of-file. This is the only method that does its own thing in this class everything else is delegated to aggregated stream. THIS IS A BLOCKING BLOCK READ!!!- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
public int read(byte[] bf, int s, int l) throws IOException
- Overrides:
read
in classInputStream
- Throws:
IOException
-
reset
public void reset() throws IOException
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
skip
public long skip(long n) throws IOException
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
-