List of usage examples for java.io EOFException EOFException
public EOFException()
EOFException
with null
as its error detail message. From source file:ReaderDataInput.java
public final void readFully(byte[] bytes, int off, int len) throws IOException { if (len < 0) { throw new IndexOutOfBoundsException(); }// w w w. jav a2 s . com int n = 0; while (n < len) { int b = read(); if (b < 0) { throw new EOFException(); } bytes[off + n++] = (byte) b; } }
From source file:org.bdval.io.compound.CompoundDataInput.java
/** * {@inheritDoc}/* w w w .j a v a 2 s .c om*/ */ public void readFully(final byte[] b, final int off, final int len) throws IOException { fileSize -= len; if (fileSize < 0) { throw new EOFException(); } dataInput.readFully(b, off, len); }
From source file:ReaderDataInput.java
public final boolean readBoolean() throws IOException { int b = read(); if (b < 0) { throw new EOFException(); }/*from w w w.java 2s . c o m*/ return (b != 0); }
From source file:org.bdval.io.compound.CompoundDataInput.java
/** * {@inheritDoc}//from w w w . j a v a 2 s . c o m */ public int skipBytes(final int n) throws IOException { fileSize -= n; if (fileSize < 0) { throw new EOFException(); } return dataInput.skipBytes(n); }
From source file:ReaderDataInput.java
public final byte readByte() throws IOException { int b = read(); if (b < 0) { throw new EOFException(); }// w ww . j av a2s. c o m return (byte) b; }
From source file:com.blackducksoftware.integration.hub.ScannerSplitStream.java
@Override public void write(final int codePoint) throws IOException { outputFileStream.write(codePoint);//from w w w . j av a 2 s . co m if (EOF == codePoint) { throw new EOFException(); } boolean atLineEnd = false; if (ETX == codePoint || EOT == codePoint) { atLineEnd = true; } else if (LF == codePoint && CR != previousCodePoint) { atLineEnd = true; } else if (LF == codePoint && CR == previousCodePoint) { atLineEnd = true; // also need to remove the previously consumed CR currentLine = currentLine.substring(0, currentLine.length() - 1); } else if (LF != codePoint && CR == previousCodePoint) { processLine(currentLine); currentLine = ""; } previousCodePoint = codePoint; if (atLineEnd) { processLine(currentLine); currentLine = ""; } else { final String stringAscii = new String(Character.toChars(codePoint)); currentLine += stringAscii; } }
From source file:com.moilioncircle.redis.replicator.io.AsyncBufferedInputStream.java
public void run() { try {/*from w w w. j a v a 2s. c o m*/ final byte[] buffer = new byte[512 * 1024]; while (!this.closed.get()) { // int r = this.is.read(buffer, 0, buffer.length); if (r < 0) throw new EOFException(); // int offset = 0; while (r > 0) { final int w = write(buffer, offset, r); r -= w; offset += w; } } } catch (IOException e) { this.exception = e; } catch (Exception e) { logger.error("failed to transfer data", e); } finally { if (!this.closed.get()) { try { close(); } catch (IOException e) { logger.error("failed to close is", e); } } } }
From source file:org.apache.hawq.pxf.service.io.GPDBWritableTest.java
@Test public void testReadFieldsFirstIntOK() throws Exception { GPDBWritable gpdbWritable = buildGPDBWritable(); int[] firstInt = new int[] { -2 }; buildStream(firstInt, true);/* w w w .jav a 2 s.c om*/ when(inputStream.readShort()).thenThrow(new EOFException()); try { gpdbWritable.readFields(inputStream); } catch (EOFException e) { assertTrue(true); } catch (Exception e) { assertTrue(false); } assertFalse(gpdbWritable.isEmpty()); // len < 0 firstInt = new int[] { 8 }; buildStream(firstInt, true); when(inputStream.readShort()).thenThrow(new EOFException()); try { gpdbWritable.readFields(inputStream); } catch (EOFException e) { assertTrue(true); } catch (Exception e) { assertTrue(false); } assertFalse(gpdbWritable.isEmpty()); // len > 0 }
From source file:org.bdval.io.compound.CompoundDataInput.java
/** * {@inheritDoc}/* w w w . j a v a 2 s. c om*/ */ public boolean readBoolean() throws IOException { fileSize -= 1; if (fileSize < 0) { throw new EOFException(); } return dataInput.readBoolean(); }
From source file:ReaderDataInput.java
public final int readUnsignedByte() throws IOException { int b = read(); if (b < 0) { throw new EOFException(); }/*www . j ava 2s. c o m*/ return b; }