Code example for ClosedChannelException

0
    // -1 will be returned if there is nothing to read; higher-level methods like readInt 
    // or readFully (from RandomAccessFile) will throw EOFException but this should not 
    public int read(byte[] buff, int offset, int length) throws IOException
    { 
        if (buffer == null)
            throw new ClosedChannelException();
 
        if (length == 0)
            return 0; 
 
        if (isEOF()) 
            return -1; 
 
        if (current >= bufferOffset + buffer.length || validBufferBytes == -1)
            reBuffer(); 
 
        assert current >= bufferOffset && current < bufferOffset + validBufferBytes
                : String.format("File (%s), current offset %d, buffer offset %d, buffer limit %d",
                                getPath(), 
                                current,
                                bufferOffset,