org.dmonix.io
Class NullInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byorg.dmonix.io.NullInputStream

public class NullInputStream
extends java.io.InputStream

The class simulates the functionality provided by reading from /dev/null/.
I.e. the same value (default null) will continously be returned.
There will be no end to the data read from this stream.

Copyright: Copyright (c) 2005

Company: dmonix.org

Version:
1.0
Author:
Peter Nerg

Constructor Summary
NullInputStream()
          Creates a stream that always returns the byte value 0 (null).
NullInputStream(byte value)
          Creates a stream that always returns the provided byte value.
 
Method Summary
 int read()
          Reads the next byte of data from the input stream.
 int read(byte[] b)
          Stores the pre defined byte value in the provided array.
 int read(byte[] b, int offset, int length)
          Stores the pre defined byte value in the provided array.
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NullInputStream

public NullInputStream()
Creates a stream that always returns the byte value 0 (null).


NullInputStream

public NullInputStream(byte value)
Creates a stream that always returns the provided byte value.

Parameters:
value - The value to use in the read methods
Method Detail

read

public int read()
         throws java.io.IOException
Reads the next byte of data from the input stream.
The method will always return the same value.

Returns:
The byte value
Throws:
java.io.IOException

read

public int read(byte[] b,
                int offset,
                int length)
         throws java.io.IOException
Stores the pre defined byte value in the provided array.

Parameters:
b - The array to store data in
offset - The offset to where to start storing data in the array
length - The number of bytes to store in the array
Returns:
The number of bytes in the array, always the same as the length argument
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Stores the pre defined byte value in the provided array.
This is the same as: read(b, 0, b.length)

Parameters:
b - The array to store data in
Returns:
The number of bytes in the array, always the same as the length of the array
Throws:
java.io.IOException


Copyright © 1998-2005 dmonix.org Peter Nerg, All Rights Reserved.