org.ssonet.io
Class ByteIOStream

java.lang.Object
  |
  +--org.ssonet.io.ByteIOStream
All Implemented Interfaces:
IOStream

public class ByteIOStream
extends java.lang.Object
implements IOStream

This class constructs an IOStream from an Input- and an Outputstream.

Version:
$Id: ByteIOStream.java,v 1.2 2003/10/20 13:33:30 tk4 Exp $
Author:
SSONET

Field Summary
static boolean debug
           
(package private)  java.io.InputStream is
           
(package private)  java.io.OutputStream os
           
(package private)  int totalReadCount
          for debugging purposes: count bytes read
 
Constructor Summary
ByteIOStream(java.io.InputStream inputStream, java.io.OutputStream outputStream)
          Constructs an IOStream.
 
Method Summary
 int available()
          Returns number of bytes which can be read without blocking.
 void closeIn()
          Closes underlying InputStream.
 void closeOut()
          Closes underlying OutputStream.
 int read(byte[] buffer)
          Reads into a buffer from the underlying stream.
 void write(byte[] buffer)
          Writes buffer to the underlying stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

public static boolean debug

is

java.io.InputStream is

os

java.io.OutputStream os

totalReadCount

int totalReadCount
for debugging purposes: count bytes read

Constructor Detail

ByteIOStream

public ByteIOStream(java.io.InputStream inputStream,
                    java.io.OutputStream outputStream)
Constructs an IOStream.

Parameters:
inputStream - to read from.
outputStream - to write to.
Method Detail

read

public int read(byte[] buffer)
         throws java.io.IOException
Reads into a buffer from the underlying stream. May block.

Specified by:
read in interface IOStream
Parameters:
buffer - the buffer, which shall be filled with bytes read
Returns:
the number of bytes read, or -1 if the End Of Stream is reached.
Throws:
java.io.IOException - if an error occures while reading from the stream
See Also:
IOStream.read(byte[])

write

public void write(byte[] buffer)
           throws java.io.IOException
Writes buffer to the underlying stream. May block.

Specified by:
write in interface IOStream
Parameters:
buffer - the buffer holding the bytes to write to the stream
Throws:
java.io.IOException - if an error occures while writing to the stream
See Also:
IOStream.write(byte[])

closeIn

public void closeIn()
             throws java.io.IOException
Closes underlying InputStream. May block.

Specified by:
closeIn in interface IOStream
java.io.IOException
See Also:
IOStream.closeIn()

closeOut

public void closeOut()
              throws java.io.IOException
Closes underlying OutputStream. May block.

Specified by:
closeOut in interface IOStream
java.io.IOException
See Also:
IOStream.closeOut()

available

public int available()
              throws java.io.IOException
Returns number of bytes which can be read without blocking.

Specified by:
available in interface IOStream
Returns:
the number of bytes currently available from the inputstream without blocking.
java.io.IOException
See Also:
IOStream.available()


Copyright © 2003 DRIM Team. All Rights Reserved.