Refine search
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; } }
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)."); } }
/** * 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; } }
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; } }
private int read() throws IOException { int v = is.read(); if (v != -1) { readBytes++; return v; } else { throw new EOFException(); } }
/** * 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; } }
/** * 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; } }
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; } }
private static byte readByteOrThrow(InputStream in) throws IOException { int b = in.read(); if (b == -1) { throw new EOFException(); } return (byte)b; } }
/** * 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; } }
@CanIgnoreReturnValue // to skip a byte @Override public int readUnsignedByte() throws IOException { int b1 = in.read(); if (0 > b1) { throw new EOFException(); } return b1; }
/** * 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; } }
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; } }
public static final byte read(InputStream in) throws IOException { int got = in.read(); if (got < 0) { throw new EOFException(); } return (byte) (got & 0xff); }
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; }
/** * 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; } }
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; }
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; } }
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; } }
public static final byte read(InputStream in) throws IOException { int got = in.read(); if (got < 0) { throw new EOFException(); } return (byte) (got & 0xff); }