public class NullInputStream
extends java.io.InputStream
Constructor and Description |
---|
NullInputStream(int numLines)
Creates an
InputStream with the given number of lines. |
NullInputStream(long size)
Creates an
InputStream with the specified size. |
NullInputStream(long size,
boolean isMarkSupported,
boolean isThrowEOF)
Creates an
InputStream with the specified size. |
Modifier and Type | Method and Description |
---|---|
int |
available()
Return the number of bytes that are still available in the stream.
|
void |
close()
Closes and resets this stream.
|
protected int |
fetchByte()
Return a byte value for the
read() method. |
long |
getPosition()
Return the current position in the stream.
|
long |
getSize()
Return the size of this
InputStream . |
void |
mark(int readLimit)
Marks the current position.
|
boolean |
markSupported()
Tells whether mark() is supported.
|
protected byte |
nextByte()
Is called whenever a byte is read from the stream.
|
int |
read()
Read the next byte from the stream.
|
int |
read(byte[] bytes)
Fill bytes into the given array.
|
int |
read(byte[] bytes,
int offset,
int length)
Fills the given array from offset with length bytes.
|
void |
reset()
Reset the stream to the last called mark.
|
long |
skip(long bytesToSkip)
Skip a specified number of bytes.
|
public NullInputStream(int numLines)
InputStream
with the given number of lines.
The size is calculated by adding a platform specific line separator to each line.public NullInputStream(long size)
InputStream
with the specified size.
It supports marking and does not throw EOFException.public NullInputStream(long size, boolean isMarkSupported, boolean isThrowEOF)
InputStream
with the specified size.size
- The size of the input streamisMarkSupported
- Tells whether this streams supports mark()isThrowEOF
- throw an EOFException
when EOF is reached, otherwise return -1.public long getPosition()
public long getSize()
InputStream
.public int available()
available
in class java.io.InputStream
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException
public void mark(int readLimit)
mark
in class java.io.InputStream
readLimit
- the maximum limit of bytes that can be read before
the mark position becomes invalid.java.lang.UnsupportedOperationException
- if mark is not supported.public boolean markSupported()
markSupported
in class java.io.InputStream
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] bytes) throws java.io.IOException
read
in class java.io.InputStream
bytes
- The byte array to be filledjava.io.IOException
public int read(byte[] bytes, int offset, int length) throws java.io.IOException
read
in class java.io.InputStream
bytes
- The byte array to be filledjava.io.IOException
public void reset() throws java.io.IOException
reset
in class java.io.InputStream
java.lang.UnsupportedOperationException
- if mark is not supported.java.io.IOException
- If no position has been marked
or the read limit has been exceeded since the last position was marked.public long skip(long bytesToSkip) throws java.io.IOException
skip
in class java.io.InputStream
bytesToSkip
- The number of bytes skipped.java.io.IOException
protected int fetchByte()
read()
method.
This implementation returns zero.
protected byte nextByte()
Copyright © 2011 EsprIT-Systems. All Rights Reserved.