org.apache.poi.util
Class BlockingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.poi.util.BlockingInputStream
All Implemented Interfaces:
java.io.Closeable

public class BlockingInputStream
extends java.io.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
protected  java.io.InputStream is
           
 
Constructor Summary
BlockingInputStream(java.io.InputStream is)
           
 
Method Summary
 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.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

is

protected java.io.InputStream is
Constructor Detail

BlockingInputStream

public BlockingInputStream(java.io.InputStream is)
Method Detail

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException

close

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

mark

public void mark(int readLimit)
Overrides:
mark in class java.io.InputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.InputStream

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] bf)
         throws java.io.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 class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] bf,
                int s,
                int l)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException


Copyright 2012 The Apache Software Foundation or its licensors, as applicable.