本文整理汇总了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;
}