public class Stream
extends java.io.InputStream
implements java.lang.Runnable
| 限定符和类型 | 字段和说明 |
|---|---|
int |
fills
The number of calls to fill.
|
byte[] |
mBuffer
The bytes read so far.
|
int |
mLevel
The number of valid bytes in the buffer.
|
int |
reallocations
The number of reallocations.
|
int |
synchronous
The number of synchronous (blocking) fills.
|
| 构造器和说明 |
|---|
Stream(java.io.InputStream in)
Construct a stream with no assumptions about the number of bytes available.
|
Stream(java.io.InputStream in,
int bytes)
Construct a stream to read the given number of bytes.
|
| 限定符和类型 | 方法和说明 |
|---|---|
int |
available()
Returns the number of bytes that can be read (or skipped over) from
this input stream without blocking by the next caller of a method for
this input stream.
|
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 byte of data from the input stream.
|
void |
reset()
Repositions this stream to the position at the time the
mark method was last called on this input stream. |
void |
run()
Continually read the underlying stream untill exhausted.
|
public int fills
public int reallocations
public int synchronous
public volatile byte[] mBuffer
public volatile int mLevel
public Stream(java.io.InputStream in)
in - The input stream to use.public Stream(java.io.InputStream in,
int bytes)
in - The input stream to use.bytes - The maximum number of bytes to read.
This should be set to the ContentLength from the HTTP header.
A negative or zero value indicates an unknown number of bytes.public void run()
run 在接口中 java.lang.RunnableThread.run()public int read()
throws java.io.IOException
int in the range 0 to
255. If no byte 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 在类中 java.io.InputStream-1 if the end of the
stream is reached.java.io.IOException - If an I/O error occurs.public int available()
throws java.io.IOException
available 在类中 java.io.InputStreamjava.io.IOException - If an I/O error occurs.public void close()
throws java.io.IOException
close 在接口中 java.io.Closeableclose 在接口中 java.lang.AutoCloseableclose 在类中 java.io.InputStreamjava.io.IOException - If an I/O error occurs.public void reset()
throws java.io.IOException
mark method was last called on this input stream.
The general contract of reset is:
markSupported returns
true, then:
mark has not been called since
the stream was created, or the number of bytes read from the stream
since mark was last called is larger than the argument
to mark at that last call, then an
IOException might be thrown.
IOException is not thrown, then the
stream is reset to a state such that all the bytes read since the
most recent call to mark (or since the start of the
file, if mark has not been called) will be resupplied
to subsequent callers of the read method, followed by
any bytes that otherwise would have been the next input data as of
the time of the call to reset. markSupported returns
false, then:
reset may throw an
IOException.
IOException is not thrown, then the stream
is reset to a fixed state that depends on the particular type of the
input stream and how it was created. The bytes that will be supplied
to subsequent callers of the read method depend on the
particular type of the input stream. reset 在类中 java.io.InputStreamjava.io.IOException - Never thrown. Just for subclassers.InputStream.mark(int),
IOExceptionpublic boolean markSupported()
mark and
reset methods. Whether or not mark and
reset are supported is an invariant property of a
particular input stream instance. The markSupported method
of InputStream returns false.markSupported 在类中 java.io.InputStreamtrue.InputStream.mark(int),
InputStream.reset()public void mark(int readlimit)
reset method repositions this stream at the last marked
position so that subsequent reads re-read the same bytes.
The readlimit arguments tells this input stream to
allow that many bytes 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 bytes read after the call to mark and
stands ready to supply those same bytes 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 bytes are
read from the stream before reset is called.
mark 在类中 java.io.InputStreamreadlimit - Not used.InputStream.reset()