下面列出了java.nio.BufferUnderflowException#getMessage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* @return non-null error description if indexer contains no data or integrity check has failed,
* and null otherwise
*/
private static String validateIntegrity(int indexerSize, byte[] validationRecord) {
if (indexerSize == 0) {
return "empty index";
}
if (validationRecord == null) {
return "no validation record";
}
try {
int validationSize = ByteBuffer.wrap(validationRecord).asIntBuffer().get();
if (validationSize <= indexerSize) {
return null;
} else {
return String.format("Validation mismatch: validation entry %d is too large " +
"compared to index size %d", validationSize, indexerSize);
}
} catch (BufferUnderflowException e) {
return e.getMessage();
}
}
@Override
public void readFully(byte b[], int off, int len) throws IOException {
try {
bb.get(b, off, len);
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public boolean readBoolean() throws IOException {
try {
int ch = bb.get();
return (ch != 0);
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public byte readByte() throws IOException {
try {
return bb.get();
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public int readUnsignedByte() throws IOException {
try {
return ((int) bb.get()) & 0xff;
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public short readShort() throws IOException {
try {
return bb.getShort();
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public int readUnsignedShort() throws IOException {
try {
return ((int) bb.getShort()) & 0xffff;
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public char readChar() throws IOException {
try {
return bb.getChar();
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public int readInt() throws IOException {
try {
return bb.getInt();
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public long readLong() throws IOException {
try {
return bb.getLong();
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public float readFloat() throws IOException {
try {
return bb.getFloat();
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public void readFully(byte b[], int off, int len) throws IOException {
try {
bb.get(b, off, len);
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public boolean readBoolean() throws IOException {
try {
int ch = bb.get();
return (ch != 0);
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public float readFloat() throws IOException {
try {
return bb.getFloat();
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public int readUnsignedByte() throws IOException {
try {
return ((int) bb.get()) & 0xff;
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public double readDouble() throws IOException {
try {
return bb.getDouble();
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public int readUnsignedShort() throws IOException {
try {
return ((int) bb.getShort()) & 0xffff;
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public char readChar() throws IOException {
try {
return bb.getChar();
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public int readInt() throws IOException {
try {
return bb.getInt();
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}
@Override
public long readLong() throws IOException {
try {
return bb.getLong();
} catch (BufferUnderflowException e) {
throw new EOFException(e.getMessage());
}
}