dap4/d4lib/src/main/java/dap4/dap4lib/ChunkInputStream.java
public int
    read()
            throws IOException
    {
        if(requestmode == RequestMode.DMR)
            throw new UnsupportedOperationException("Attempt to read databuffer when DMR only"); // Runtime
        if(avail <= 0) {
            if((flags & DapUtil.CHUNK_END) != 0)
                return -1; // Treat as EOF
            if(!readHeader(input))
                return -1; // EOF
            // See if we have an error chunk,
            // and if so, turn it into an exception
            if((flags & DapUtil.CHUNK_ERROR) != 0) {
                String document = readError();
                throwError(document);
            }
        }
        avail--;
        return input.read();
    }
public int
    read()
            throws IOException
    {
        if(requestmode == RequestMode.DMR)
            throw new UnsupportedOperationException("Attempt to read databuffer when DMR only"); // Runtime
        if(avail <= 0) {
            if((flags & DapUtil.CHUNK_END) != 0)
                return -1; // Treat as EOF
            if(!readHeader(input))
                return -1; // EOF
            // See if we have an error chunk,
            // and if so, turn it into an exception
            if((flags & DapUtil.CHUNK_ERROR) != 0) {
                String document = readError();
                throwError(document);
            }
        }
        avail--;
        return input.read();
    }
public int read ( ) throws IOException { if ( requestmode == RequestMode . DMR ) throw new UnsupportedOperationException ( "Attempt to read databuffer when DMR only" ) ; // Runtime if ( avail <= 0 ) { if ( ( flags & DapUtil . CHUNK_END ) != 0 ) return - 1 ; // Treat as EOF if ( ! readHeader ( input ) ) return - 1 ; // EOF // See if we have an error chunk, // and if so, turn it into an exception if ( ( flags & DapUtil . CHUNK_ERROR ) != 0 ) { String document = readError ( ) ; throwError ( document ) ; } } avail -- ; return input . read ( ) ; }
Reads the next byte of databuffer 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 databuffer is available, the end of the stream is detected,
or an exception is thrown.
<p>
Operates by loading chunk by chunk. If an error chunk is detected,
then return ErrorException (which is a subclass of IOException).

@return the next byte of databuffer, or <code>-1</code> if the end of the
stream is reached.
@throws IOException if an I/O error occurs.
Reads the next byte of databuffer 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 databuffer is available the end of the stream is detected or an exception is thrown . <p > Operates by loading chunk by chunk . If an error chunk is detected then return ErrorException ( which is a subclass of IOException ) .