List of usage examples for java.io EOFException EOFException
public EOFException(String s)
EOFException
with the specified detail message. From source file:com.tomagoyaky.jdwp.IOUtils.java
/** * Reads the requested number of bytes or fail if there are not enough left. * <p/>//from www . j a v a 2 s . co m * This allows for the possibility that {@link InputStream#read(byte[], int, int)} may * not read as many bytes as requested (most likely because of reaching EOF). * * @param input where to read input from * @param buffer destination * @param offset initial offset into buffer * @param length length to read, must be >= 0 * @throws IOException if there is a problem reading the file * @throws IllegalArgumentException if length is negative * @throws EOFException if the number of bytes read was incorrect * @since 2.2 */ public static void readFully(final InputStream input, final byte[] buffer, final int offset, final int length) throws IOException { final int actual = read(input, buffer, offset, length); if (actual != length) { throw new EOFException("Length to read: " + length + " actual: " + actual); } }
From source file:org.apache.geode.internal.cache.Oplog.java
private void readEndOfRecord(DataInput di) throws IOException { int b = di.readByte(); if (b != END_OF_RECORD_ID) { if (b == 0) { logger.warn(LocalizedMessage.create(LocalizedStrings.Oplog_PARTIAL_RECORD)); // this is expected if this is the last record and we died while writing // it. throw new EOFException("found partial last record"); } else {//from w w w.j a v a 2s.co m // Our implementation currently relies on all unwritten bytes having // a value of 0. So throw this exception if we find one we didn't // expect. throw new IllegalStateException( "expected end of record (byte==" + END_OF_RECORD_ID + ") or zero but found " + b); } } }
From source file:com.tomagoyaky.jdwp.IOUtils.java
/** * Reads the requested number of bytes or fail if there are not enough left. * <p/>//w w w. j a v a 2s . c o m * This allows for the possibility that {@link ReadableByteChannel#read(ByteBuffer)} may * not read as many bytes as requested (most likely because of reaching EOF). * * @param input the byte channel to read * @param buffer byte buffer destination * @throws IOException if there is a problem reading the file * @throws EOFException if the number of bytes read was incorrect * @since 2.2 */ public static void readFully(final ReadableByteChannel input, final ByteBuffer buffer) throws IOException { final int expected = buffer.remaining(); final int actual = read(input, buffer); if (actual != expected) { throw new EOFException("Length to read: " + expected + " actual: " + actual); } }
From source file:com.clark.func.Functions.java
/** * Skip the requested number of characters or fail if there are not enough * left.//from w w w.j a v a 2s. com * <p> * This allows for the possibility that {@link Reader#skip(long)} may not * skip as many characters as requested (most likely because of reaching * EOF). * * @param input * stream to skip * @param toSkip * the number of characters to skip * @see Reader#skip(long) * * @throws IOException * if there is a problem reading the file * @throws IllegalArgumentException * if toSkip is negative * @throws EOFException * if the number of characters skipped was incorrect * @since Commons IO 2.0 */ public static void skipFully(Reader input, long toSkip) throws IOException { long skipped = skip(input, toSkip); if (skipped != toSkip) { throw new EOFException("Bytes to skip: " + toSkip + " actual: " + skipped); } }
From source file:com.clark.func.Functions.java
/** * Reads the next byte from the input stream. * //from ww w . ja v a 2 s . c om * @param input * the stream * @return the byte * @throws IOException * if the end of file is reached */ private static int readInternal(InputStream input) throws IOException { int value = input.read(); if (-1 == value) { throw new EOFException("Unexpected EOF reached"); } return value; }