com.brackeen.javagamebook.util
Class LoopingByteInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byjava.io.ByteArrayInputStream
          extended bycom.brackeen.javagamebook.util.LoopingByteInputStream

public class LoopingByteInputStream
extends java.io.ByteArrayInputStream

The LoopingByteInputStream is a ByteArrayInputStream that loops indefinitly. The looping stops when the close() method is called.

Possible ideas to extend this class:


Constructor Summary
LoopingByteInputStream(byte[] buffer)
          Creates a new LoopingByteInputStream with the specified byte array.
 
Method Summary
 void close()
          Closes the stream.
 int read(byte[] buffer, int offset, int length)
          Reads length bytes from the array.
 
Methods inherited from class java.io.ByteArrayInputStream
available, mark, markSupported, read, reset, skip
 
Methods inherited from class java.io.InputStream
read
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoopingByteInputStream

public LoopingByteInputStream(byte[] buffer)
Creates a new LoopingByteInputStream with the specified byte array. The array is not copied.

Method Detail

read

public int read(byte[] buffer,
                int offset,
                int length)
Reads length bytes from the array. If the end of the array is reached, the reading starts over from the beginning of the array. Returns -1 if the array has been closed.


close

public void close()
           throws java.io.IOException
Closes the stream. Future calls to the read() methods will return 1.

Throws:
java.io.IOException