Tabnine Logo
EOFException
Code IndexAdd Tabnine to your IDE (free)

How to use
EOFException
in
java.io

Best Java code snippets using java.io.EOFException (Showing top 20 results out of 37,620)

Refine searchRefine arrow

  • InputStream
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: commons-io/commons-io

/**
 * Handle End of File.
 *
 * @return <code>-1</code> if <code>throwEofException</code> is
 * set to {@code false}
 * @throws EOFException if <code>throwEofException</code> is set
 * to {@code true}.
 */
private int doEndOfFile() throws EOFException {
  eof = true;
  if (throwEofException) {
    throw new EOFException();
  }
  return EOF;
}
origin: libgdx/libgdx

private void skipFully (int count) throws IOException {
  while (count > 0) {
    long skipped = in.skip(count);
    if (skipped <= 0) throw new EOFException("Unable to skip.");
    count -= skipped;
  }
}
origin: square/okio

@Test public void eofExceptionProvidesLimitedContent() throws IOException {
 data.writeUtf8("aaaaaaaabbbbbbbbccccccccdddddddde");
 try {
  source.readUtf8LineStrict();
  fail();
 } catch (EOFException expected) {
  assertEquals("\\n not found: limit=33 content=616161616161616162626262626262626363636363636363"
    + "6464646464646464…", expected.getMessage());
 }
}
origin: apache/flink

@Override
public int readUnsignedByte() throws IOException {
  if (this.position < this.end) {
    return (this.buffer[this.position++] & 0xff);
  } else {
    throw new EOFException();
  }
}
origin: libgdx/libgdx

private void skipFully (int count) throws IOException {
  while (count > 0) {
    long skipped = in.skip(count);
    if (skipped <= 0) throw new EOFException("Unable to skip.");
    count -= skipped;
  }
}
origin: square/okio

@Test public void readUtf8LineStrictNoBytesConsumedOnFailure() throws IOException {
 data.writeUtf8("abc\n");
 try {
  source.readUtf8LineStrict(2);
  fail();
 } catch (EOFException expected) {
  assertTrue(expected.getMessage().startsWith("\\n not found: limit=2 content=61626"));
 }
 assertEquals("abc", source.readUtf8LineStrict(3));
}
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: apache/flink

@Override
public void skipBytesToWrite(int numBytes) throws IOException {
  if (buffer.length - this.position < numBytes){
    throw new EOFException("Could not skip " + numBytes + " bytes.");
  }
  this.position += numBytes;
}
origin: libgdx/libgdx

private void skipFully (int count) throws IOException {
  while (count > 0) {
    long skipped = in.skip(count);
    if (skipped <= 0) throw new EOFException("Unable to skip.");
    count -= skipped;
  }
}
origin: square/okio

@Test public void readLines() throws IOException {
 data.writeUtf8("abc\ndef\n");
 assertEquals("abc", source.readUtf8LineStrict());
 assertEquals("def", source.readUtf8LineStrict());
 try {
  source.readUtf8LineStrict();
  fail();
 } catch (EOFException expected) {
  assertEquals("\\n not found: limit=0 content=…", expected.getMessage());
 }
}
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

@Override
public char readChar() throws IOException {
  if (this.position < this.end - 1) {
    return (char) (((this.memory[this.position++] & 0xff) << 8) | ((this.memory[this.position++] & 0xff) << 0));
  } else {
    throw new EOFException();
  }
}
origin: libgdx/libgdx

private void skipFully (int count) throws IOException {
  while (count > 0) {
    long skipped = in.skip(count);
    if (skipped <= 0) throw new EOFException("Unable to skip.");
    count -= skipped;
  }
}
origin: prestodb/presto

private int read() throws IOException {
  int v = is.read();
  if (v != -1) {
    readBytes++;
    return v;
  } else {
    throw new EOFException();
  }
}
origin: apache/flink

@Override
public short readShort() throws IOException {
  if (position >= 0 && position < this.end - 1) {
    return (short) ((((this.memory[position++]) & 0xff) << 8) | (((this.memory[position++]) & 0xff) << 0));
  } else {
    throw new EOFException();
  }
}
origin: apache/flink

@Override
public void seek(long desired) throws IOException {
  if (desired < this.pos) {
    throw new IllegalArgumentException("Wrapped InputStream: cannot search backwards.");
  }
  while (this.pos < desired) {
    long numReadBytes = this.inStream.skip(desired - pos);
    if (numReadBytes == -1) {
      throw new EOFException("Unexpected EOF during forward seek.");
    }
    this.pos += numReadBytes;
  }
}
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: apache/flink

@Override
public boolean readBoolean() throws IOException {
  if (this.position < this.end) {
    return this.buffer[this.position++] != 0;
  } else {
    throw new EOFException();
  }
}
origin: square/spoon

public final void skip(int bytes) throws IOException {
  if (bytes<=0) {
    return;
  }
  long skipped=m_stream.skip(bytes);
  m_position+=skipped;
  if (skipped!=bytes) {
    throw new EOFException();
  }
}
java.ioEOFException

Javadoc

Thrown when a program encounters the end of a file or stream during an input operation.

Most used methods

  • <init>
    Constructs a new EOFException with its stack trace and detail message filled in.
  • getMessage
  • printStackTrace
  • initCause
  • toString
  • addSuppressed
  • getStackTrace
  • setStackTrace
  • getLocalizedMessage
  • getCause

Popular in Java

  • Updating database using SQL prepared statement
  • getResourceAsStream (ClassLoader)
  • onRequestPermissionsResult (Fragment)
  • runOnUiThread (Activity)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • JComboBox (javax.swing)
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now