tags: InputStream Repeatable read
// BufferedInputStream snippet:
public synchronized int read() throws IOException {
if (pos >= count) {
fill();
if (pos >= count)
return -1;
}
return getBufIfOpen()[pos++] & 0xff;
}
// FileInputStream snippet:
public native int read() throws IOException;
public ByteArrayInputStream(byte buf[]) {
this.buf = buf;
this.pos = 0;
this.count = buf.length;
}
public synchronized int read() {
return (pos < count) ? (buf[pos++] & 0xff) : -1;
}
/**
* Reads the next byte of data from the input stream. The value byte is
* returned as an <code>int</code> in the range <code>0</code> to
* <code>255</code>. If no byte is available because the end of the stream
* has been reached, the value <code>-1</code> is returned. This method
* blocks until input data is available, the end of the stream is detected,
* or an exception is thrown.
*
* <p> A subclass must provide an implementation of this method.
*
* @return the next byte of data, or <code>-1</code> if the end of the
* stream is reached.
* @exception IOException if an I/O error occurs.
*/
public abstract int read() throws IOException;
At the same time of development, sometimes you need to read the InputStream multiple times, but it is null after a read, you can use the following class to solve ...
InputStream repeated reading The introduction of the problem stream read only once, with System.out.println (); if printed flow will result if the stream is read once again read after use will lead to...
Recently, I plan to add the verification signature function to the previous project APP interface. The implementation idea is very simple. It is to add all the request parameters in the filter by addi...
Read inputSeream read in once after Filter will not be able to read again, the solution is as follows: Call follows Tools below ...
There is a need to perform two operations to the same file, one is the upload file to store the current node, one is the synchronization file to other nodes. Because the stream can only be read once. ...
inputstream can only be read once again you can not get to read the content. This is because the internal inputStream have a pos pointer, when read pointer will continue to move, when to move to the e...
InputStream the read method November 20, 2018 14:48:47baidu_38284985Read the number 600 This InputStream abstract class is a superclass of all the input stream of bytes. We read from the input data st...
InputStream read stream has three methods, namely read (), read (byte [] b), read (byte [] b, int off, int len). The read() method reads one byte at a time, and the efficiency is very low. So it is be...