public class HexStringInputStream extends InputStream
HexInputStream, except its constructor takes a
String as input to read.HexInputStream| Constructor and Description |
|---|
HexStringInputStream(String s)
Initializes this stream with another input stream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this input stream and releases any system resources associated with the stream.
|
void |
mark(int readlimit)
Marks the current position in this input stream.
|
boolean |
markSupported()
Tests if this input stream supports the mark and reset methods.
|
int |
read()
Reads the next char of data from the input stream.
|
int |
read(char[] b)
This method has the same effect as
read(b, 0, b.length). |
int |
read(char[] b,
int off,
int len)
Reads up to
len chars of data from another String into an array of chars. |
void |
reset()
Repositions this stream to the position at the time the
mark method was last
called on this input stream. |
long |
skip(long n)
Skips over and discards
n chars of data from this input stream. |
available, read, readpublic HexStringInputStream(String s)
s - The string from which yet-to-be-converted input should be received.public int read()
throws IOException
int in the range 0 to 255. If no char is available because the end of the stream
has been reached, the value -1 is returned. This method blocks until input data is available,
the end of the stream is detected, or an exception is thrown.read in class InputStreamIOExceptionpublic int read(char[] b)
throws IOException
read(b, 0, b.length).b - A buffer in which the converted input is stored.IOExceptionpublic int read(char[] b,
int off,
int len)
throws IOException
len chars of data from another String into an array of chars. An
attempt is made to read as many as len chars, but a smaller number may be read,
possibly zero. The number of chars actually read is returned as an integer. b is null, a NullPointerException is thrown. off is negative, or len is negative, or off+len is
greater than the length of the array b, then an
IndexOutOfBoundsException is thrown. len is zero, then no chars are read and 0 is returned; otherwise, there is an
attempt to read at least one char. If no char is available because the stream is at end of
file, the value -1 is returned; otherwise, at least one char is read and stored into
b. b[off], the next one into
b[off+1], and so on. The number of chars read is, at most, equal to
len. Let k be the number of chars actually read; these chars will be
stored in elements b[off] through b[off+k-1], leaving elements
b[off+k] through b[off+len-1] unaffected. b[0] through b[off-1] and elements
b[off+len] through b[b.length-1] are unaffected. IOException is thrown. In particular, an IOException is thrown if
the input stream has been closed.b - A buffer into which the converted input is stored.off - The offset in the buffer at which to begin writing.len - The amount of chars to be received and written into the buffer.IOExceptionpublic long skip(long n)
throws IOException
n chars of data from this input stream. The skip method
may, for a variety of reasons, end up skipping over some smaller number of chars, possibly 0.
This may result from any of a number of conditions; reaching end of file before
n chars have been skipped is only one possibility. The actual number of chars
skipped is returned. If n is negative, no chars are skipped.skip in class InputStreamn - The number of chars to be skipped.IOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionpublic void mark(int readlimit)
reset
method repositions this stream at the last marked position so that subsequent reads re-read
the same chars.
The readlimit argument tells this input stream to allow that many chars to be
read before the mark position gets invalidated.
The general contract of mark is that, if the method markSupported returns
true, the stream somehow remembers all the chars read after the call to mark and
stands ready to supply those same chars again if and whenever the method reset
is called. However, the stream is not required to remember any data at all if more than
readlimit chars are read from the stream before reset is called.mark in class InputStreamreadlimit - The maximum limit of chars that can be read before the mark position becomes
invalid.public void reset()
throws IOException
mark method was last
called on this input stream.reset in class InputStreamIOExceptionpublic boolean markSupported()
mark and reset are supported is an invariant property of the
provided input stream instance.markSupported in class InputStreamtrue iff the provided input stream instance supports the
mark and reset methods.Copyright © 2016. All rights reserved.