本文整理了Java中java.io.EOFException.<init>()
方法的一些代码示例,展示了EOFException.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EOFException.<init>()
方法的具体详情如下:
包路径:java.io.EOFException
类名称:EOFException
方法名:<init>
[英]Constructs a new EOFException with its stack trace filled in.
[中]构造一个新的EOFEException,并填充其堆栈跟踪。
代码示例来源:origin: libgdx/libgdx
public void readFully (byte[] b, int off, int len) throws IOException {
while (len > 0) {
int count = is.read(b, off, len);
if (count <= 0) {
throw new EOFException();
}
off += count;
len -= count;
}
}
代码示例来源:origin: apache/flink
private void resize(int minCapacityAdd) throws IOException {
try {
int newLen = Math.max(this.buffer.length * 2, this.buffer.length + minCapacityAdd);
if (newLen > maxSize) {
if (this.buffer.length + minCapacityAdd > maxSize) {
throw new EOFException("Exceeded maximum capacity");
}
newLen = maxSize;
}
final byte[] nb = new byte[newLen];
System.arraycopy(this.buffer, 0, nb, 0, this.position);
this.buffer = nb;
this.wrapper = ByteBuffer.wrap(this.buffer);
}
catch (NegativeArraySizeException nasex) {
throw new IOException("Serialization failed because the record length would exceed 2GB (max addressable array size in Java).");
}
}
代码示例来源:origin: google/guava
/**
* Reads a byte from the input stream checking that the end of file (EOF) has not been
* encountered.
*
* @return byte read from input
* @throws IOException if an error is encountered while reading
* @throws EOFException if the end of file (EOF) is encountered.
*/
private byte readAndCheckByte() throws IOException, EOFException {
int b1 = in.read();
if (-1 == b1) {
throw new EOFException();
}
return (byte) b1;
}
}
代码示例来源:origin: libgdx/libgdx
public void readFully (byte[] b, int off, int len) throws IOException {
while (len > 0) {
int count = is.read(b, off, len);
if (count <= 0) {
throw new EOFException();
}
off += count;
len -= count;
}
}
代码示例来源:origin: prestodb/presto
private int read() throws IOException {
int v = is.read();
if (v != -1) {
readBytes++;
return v;
} else {
throw new EOFException();
}
}
代码示例来源:origin: commons-io/commons-io
/**
* Reads the next byte from the input stream.
* @param input the stream
* @return the byte
* @throws IOException if the end of file is reached
*/
private static int read(final InputStream input)
throws IOException
{
final int value = input.read();
if( EOF == value ) {
throw new EOFException( "Unexpected EOF reached" );
}
return value;
}
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
/**
* Reads new input data into the buffer. Call only with pos == end or end == -1,
* depending on the desired outcome if the function throws.
*/
private void fillBuf() throws IOException {
int result = in.read(buf, 0, buf.length);
if (result == -1) {
throw new EOFException();
}
pos = 0;
end = result;
}
}
代码示例来源:origin: facebook/stetho
private static void readBytesOrThrow(InputStream in, byte[] buf, int offset, int count)
throws IOException {
while (count > 0) {
int n = in.read(buf, offset, count);
if (n == -1) {
throw new EOFException();
}
count -= n;
offset += n;
}
}
代码示例来源:origin: facebook/stetho
private static byte readByteOrThrow(InputStream in) throws IOException {
int b = in.read();
if (b == -1) {
throw new EOFException();
}
return (byte)b;
}
}
代码示例来源:origin: prestodb/presto
/**
* Reads a byte from the input stream checking that the end of file (EOF) has not been
* encountered.
*
* @return byte read from input
* @throws IOException if an error is encountered while reading
* @throws EOFException if the end of file (EOF) is encountered.
*/
private byte readAndCheckByte() throws IOException, EOFException {
int b1 = in.read();
if (-1 == b1) {
throw new EOFException();
}
return (byte) b1;
}
}
代码示例来源:origin: google/guava
@CanIgnoreReturnValue // to skip a byte
@Override
public int readUnsignedByte() throws IOException {
int b1 = in.read();
if (0 > b1) {
throw new EOFException();
}
return b1;
}
代码示例来源:origin: JakeWharton/DiskLruCache
/**
* Reads new input data into the buffer. Call only with pos == end or end == -1,
* depending on the desired outcome if the function throws.
*/
private void fillBuf() throws IOException {
int result = in.read(buf, 0, buf.length);
if (result == -1) {
throw new EOFException();
}
pos = 0;
end = result;
}
}
代码示例来源:origin: jankotek/mapdb
public static void readFully(InputStream in, byte[] data, int offset, int len) throws IOException {
len+=offset;
for(; offset<len;){
int c = in.read(data, offset, len - offset);
if(c<0)
throw new EOFException();
offset+=c;
}
}
代码示例来源:origin: alibaba/cobar
public static final byte read(InputStream in) throws IOException {
int got = in.read();
if (got < 0) {
throw new EOFException();
}
return (byte) (got & 0xff);
}
代码示例来源:origin: square/spoon
public final byte[] readByteArray(int length) throws IOException {
byte[] array=new byte[length];
int read=m_stream.read(array);
m_position+=read;
if (read!=length) {
throw new EOFException();
}
return array;
}
代码示例来源:origin: google/j2objc
/**
* Reads a byte from the input stream checking that the end of file (EOF) has not been
* encountered.
*
* @return byte read from input
* @throws IOException if an error is encountered while reading
* @throws EOFException if the end of file (EOF) is encountered.
*/
private byte readAndCheckByte() throws IOException, EOFException {
int b1 = in.read();
if (-1 == b1) {
throw new EOFException();
}
return (byte) b1;
}
}
代码示例来源:origin: square/spoon
public static final int readInt(InputStream stream,int length) throws IOException {
int result=0;
for (int i=0;i!=length;++i) {
int b=stream.read();
if (b==-1) {
throw new EOFException();
}
result|=(b<<(i*8));
}
return result;
}
代码示例来源:origin: alibaba/cobar
public static final void read(InputStream in, byte[] b, int offset, int length) throws IOException {
for (int got = 0; length > 0;) {
got = in.read(b, offset, length);
if (got < 0) {
throw new EOFException();
}
offset += got;
length -= got;
}
}
代码示例来源:origin: alibaba/cobar
public static final void read(InputStream in, byte[] b, int offset, int length) throws IOException {
for (int got = 0; length > 0;) {
got = in.read(b, offset, length);
if (got < 0) {
throw new EOFException();
}
offset += got;
length -= got;
}
}
代码示例来源:origin: alibaba/cobar
public static final byte read(InputStream in) throws IOException {
int got = in.read();
if (got < 0) {
throw new EOFException();
}
return (byte) (got & 0xff);
}
内容来源于网络,如有侵权,请联系作者删除!