hibergui.generator.tool.io
Class BufferedStream

java.lang.Object
  extended by java.io.InputStream
      extended by hibergui.generator.tool.io.BufferedStream
All Implemented Interfaces:
java.io.Closeable

public class BufferedStream
extends java.io.InputStream

With this class you can read data from InputStream more than once a time. If you want to reset the position of given InputStream you just have to call reset method without calling mark method before using it.

Author:
Csaba Gyenge

Field Summary
private  java.io.ByteArrayInputStream bis
           
private  byte[] buffer
           
private static int READ_SIZE
           
private  java.io.InputStream source
           
 
Constructor Summary
BufferedStream(java.io.InputStream is)
          Read data from InputStream more than once a time.
 
Method Summary
protected static byte[] buffering(java.io.InputStream is)
          Method to read data from is to an array.
 boolean markSupported()
          It is always return true because reset is always supported.
 int read()
           
 void reset()
          Call this method to reset the input stream.
 
Methods inherited from class java.io.InputStream
available, close, mark, read, read, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READ_SIZE

private static final int READ_SIZE
See Also:
Constant Field Values

source

private java.io.InputStream source

bis

private java.io.ByteArrayInputStream bis

buffer

private byte[] buffer
Constructor Detail

BufferedStream

public BufferedStream(java.io.InputStream is)
Read data from InputStream more than once a time.

Parameters:
is - InputStream to read data from.
Method Detail

buffering

protected static byte[] buffering(java.io.InputStream is)
                           throws java.io.IOException
Method to read data from is to an array.

Returns:
Array of byte which contains data of given is input stream
Throws:
java.io.IOException

read

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

reset

public void reset()
           throws java.io.IOException
Call this method to reset the input stream. You don't need to use mark method, or something else before calling this method.

Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

markSupported

public boolean markSupported()
It is always return true because reset is always supported.

Overrides:
markSupported in class java.io.InputStream
Returns:
Constant true value.