Package com.amazonaws.test.util
Class RandomInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.amazonaws.test.util.RandomInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
UnreliableRandomInputStream
public class RandomInputStream extends InputStream
Test utility InputStream implementation that generates random ASCII data when read, up to the size specified when constructed.- Author:
- Jason Fulghum
-
-
Field Summary
Fields Modifier and Type Field Description protected longlengthInBytesThe requested amount of data contained in this random streamprotected longremainingBytesThe number of bytes of data remaining in this random stream
-
Constructor Summary
Constructors Constructor Description RandomInputStream(long lengthInBytes)Constructs a new InputStream, which will return the specified amount of bytes of random ASCII characters.RandomInputStream(long lengthInBytes, boolean binaryData)Creates a new random input stream of specified length, and specifies whether the stream should be full on binary or character data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetBytesRead()intread()intread(byte[] b, int off, int len)-
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
-
-
-
Constructor Detail
-
RandomInputStream
public RandomInputStream(long lengthInBytes)
Constructs a new InputStream, which will return the specified amount of bytes of random ASCII characters.- Parameters:
lengthInBytes- The size in bytes of the total data returned by this stream.
-
RandomInputStream
public RandomInputStream(long lengthInBytes, boolean binaryData)Creates a new random input stream of specified length, and specifies whether the stream should be full on binary or character data.- Parameters:
lengthInBytes- The number of bytes in the stream.binaryData- Whether binary or character data should be generated.
-
-
Method Detail
-
read
public int read(byte[] b, int off, int len) throws IOException- Overrides:
readin classInputStream- Throws:
IOException
-
read
public int read() throws IOException- Specified by:
readin classInputStream- Throws:
IOException
-
getBytesRead
public long getBytesRead()
-
-