Java Code Examples for java.io.EOFException#initCause()

The following examples show how to use java.io.EOFException#initCause() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamReader.java    From HtmlNative with Apache License 2.0 5 votes vote down vote up
@Override
public char nextCh() throws EOFException {
    try {
        if (tempPos == tempCount - 1) {
            if (meetEof) {
                throw new EOFException("Reach the end of stream!");
            }
            fillInCache();
        }
        ch = temp[tempPos + 1];
        tempPos++;
        column++;

        if (ch == '\n' || ch == '\r') {
            this.line++;
            column = 1;
        }

        countOfRead++;
        return ch;

    } catch (IOException e) {
        close();
        if (e instanceof EOFException) {
            throw (EOFException) e;
        }
        EOFException eofException = new EOFException();
        eofException.initCause(e);
        throw eofException;
    }
}
 
Example 2
Source File: FileNioMapped.java    From dble with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized int read(ByteBuffer dst) throws IOException {
    try {
        int len = dst.remaining();
        if (len == 0) {
            return 0;
        }
        len = (int) Math.min(len, fileLength - pos);
        if (len <= 0) {
            return -1;
        }
        mapped.position(pos);
        if (dst instanceof DirectBuffer) {
            byte[] temp = new byte[len];
            mapped.get(temp, 0, len);
            dst.put(temp);
        } else {
            mapped.get(dst.array(), dst.arrayOffset() + dst.position(), len);
            dst.position(dst.position() + len);
        }
        pos += len;
        return len;
    } catch (IllegalArgumentException | BufferUnderflowException e) {
        EOFException e2 = new EOFException("EOF");
        e2.initCause(e);
        throw e2;
    }
}
 
Example 3
Source File: BaseDecoder.java    From hbase with Apache License 2.0 5 votes vote down vote up
private void rethrowEofException(IOException ioEx) throws IOException {
  boolean isEof = false;
  try {
    isEof = this.in.available() == 0;
  } catch (Throwable t) {
    LOG.trace("Error getting available for error message - ignoring", t);
  }
  if (!isEof) throw ioEx;
  if (LOG.isTraceEnabled()) {
    LOG.trace("Partial cell read caused by EOF", ioEx);
  }
  EOFException eofEx = new EOFException("Partial cell read");
  eofEx.initCause(ioEx);
  throw eofEx;
}
 
Example 4
Source File: BinaryCompatibleBaseDecoder.java    From phoenix with Apache License 2.0 5 votes vote down vote up
private void rethrowEofException(IOException ioEx) throws IOException {
  boolean isEof = false;
  try {
    isEof = this.in.available() == 0;
  } catch (Throwable t) {
    LOGGER.trace("Error getting available for error message - ignoring", t);
  }
  if (!isEof) throw ioEx;
  if (LOGGER.isTraceEnabled()) {
    LOGGER.trace("Partial cell read caused by EOF", ioEx);
  }
  EOFException eofEx = new EOFException("Partial cell read");
  eofEx.initCause(ioEx);
  throw eofEx;
}
 
Example 5
Source File: ByteBufStreamInput.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public short readShort() throws IOException {
    try {
        return buffer.readShort();
    } catch (IndexOutOfBoundsException ex) {
        EOFException eofException = new EOFException();
        eofException.initCause(ex);
        throw eofException;
    }
}
 
Example 6
Source File: ByteBufStreamInput.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public int readInt() throws IOException {
    try {
        return buffer.readInt();
    } catch (IndexOutOfBoundsException ex) {
        EOFException eofException = new EOFException();
        eofException.initCause(ex);
        throw eofException;
    }
}
 
Example 7
Source File: ByteBufStreamInput.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public long readLong() throws IOException {
    try {
        return buffer.readLong();
    } catch (IndexOutOfBoundsException ex) {
        EOFException eofException = new EOFException();
        eofException.initCause(ex);
        throw eofException;
    }
}
 
Example 8
Source File: ByteBufStreamInput.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public byte readByte() throws IOException {
    try {
        return buffer.readByte();
    } catch (IndexOutOfBoundsException ex) {
        EOFException eofException = new EOFException();
        eofException.initCause(ex);
        throw eofException;
    }
}
 
Example 9
Source File: ByteBufferStreamInput.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public short readShort() throws IOException {
    try {
        return buffer.getShort();
    } catch (BufferUnderflowException ex) {
        EOFException eofException = new EOFException();
        eofException.initCause(ex);
        throw eofException;
    }
}
 
Example 10
Source File: ByteBufferStreamInput.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public int readInt() throws IOException {
    try {
        return buffer.getInt();
    } catch (BufferUnderflowException ex) {
        EOFException eofException = new EOFException();
        eofException.initCause(ex);
        throw eofException;
    }
}
 
Example 11
Source File: ByteBufferStreamInput.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public long readLong() throws IOException {
    try {
        return buffer.getLong();
    } catch (BufferUnderflowException ex) {
        EOFException eofException = new EOFException();
        eofException.initCause(ex);
        throw eofException;
    }
}