public class Support_ASimpleInputStream extends InputStream
An implementation of {@code InputStream} that should serve as the
underlying stream for classes to be tested.
In particular this implementation allows to have IOExecptions thrown on demand.
For simplicity of use and understanding all fields are public.
Fields Summary
public static final int
DEFAULT_BUFFER_SIZE
public byte[]
buf
public int
pos
public int
len
public boolean
throwExceptionOnNextUse
Constructors Summary
public Support_ASimpleInputStream()
this("BEGIN Bla bla, some text...END");
public Support_ASimpleInputStream(boolean throwException)
if (throwExceptionOnNextUse) {
throw new IOException("Exception thrown for testing purpose.");
}
if (pos < len) {
int res = buf[pos];
pos++;
return res;
} else {
return -1;
}