本文整理匯總了Java中java.io.EOFException.initCause方法的典型用法代碼示例。如果您正苦於以下問題:Java EOFException.initCause方法的具體用法?Java EOFException.initCause怎麽用?Java EOFException.initCause使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.io.EOFException
的用法示例。
在下文中一共展示了EOFException.initCause方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: nextCh
import java.io.EOFException; //導入方法依賴的package包/類
@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;
}
}
示例2: read
import java.io.EOFException; //導入方法依賴的package包/類
@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;
}
}
示例3: rethrowEofException
import java.io.EOFException; //導入方法依賴的package包/類
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;
}