/** * Fills 'dst' with bytes from 'in', throwing EOFException if insufficient bytes are available. */ public static void readFully(InputStream in, byte[] dst) throws IOException { readFully(in, dst, 0, dst.length); }
/** * Returns a byte[] containing the remainder of 'in', closing it when done. */ public static byte[] readFully(InputStream in) throws IOException { try { return readFullyNoClose(in); } finally { in.close(); } }
/** * Reads a byte from the compressed input stream. The result will be a byte of compressed * data corresponding to an uncompressed byte or bytes read from the underlying stream. * * @return the byte or -1 if the end of the stream has been reached. */ @Override public int read() throws IOException { return Streams.readSingleByte(this); }
@Override public long skip(long byteCount) throws IOException { return Streams.skipByReading(this, byteCount); } }
/** * Writes the single byte to this cipher output stream. * * @param b * the byte to write. * @throws IOException * if an error occurs. */ @Override public void write(int b) throws IOException { Streams.writeSingleByte(this, b); }
Streams.skipAll(this); } catch (Exception e) { failure = e;
/** * Skip up to {@code byteCount} bytes of data on the underlying input * stream. Any skipped bytes are added to the running checksum value. * * @param byteCount the number of bytes to skip. * @throws IOException if this stream is closed or another I/O error occurs. * @return the number of bytes skipped. */ @Override public long skip(long byteCount) throws IOException { return Streams.skipByReading(this, byteCount); } }
@Override public void write(int oneByte) throws IOException { Streams.writeSingleByte(this, oneByte); }
public final void readFully(byte[] dst, int offset, int byteCount) throws IOException { Streams.readFully(in, dst, offset, byteCount); }
/** * Reads a single byte of decompressed data. * * @return the byte read. * @throws IOException * if an error occurs reading the byte. */ @Override public int read() throws IOException { return Streams.readSingleByte(this); }
/** * Merges name/attribute pairs read from the input stream {@code is} into this manifest. * * @param is * The {@code InputStream} to read from. * @throws IOException * If an error occurs reading the manifest. */ public void read(InputStream is) throws IOException { byte[] buf; if (is instanceof ByteArrayInputStream) { buf = exposeByteArrayInputStreamBytes((ByteArrayInputStream) is); } else { buf = Streams.readFullyNoClose(is); } if (buf.length == 0) { return; } // a workaround for HARMONY-5662 // replace EOF and NUL with another new line // which does not trigger an error byte b = buf[buf.length - 1]; if (b == 0 || b == 26) { buf[buf.length - 1] = '\n'; } ManifestReader im = new ManifestReader(buf, mainAttributes); mainEnd = im.getEndOfMainSection(); im.readEntries(entries, chunks); }
@Override public long skip(long byteCount) throws IOException { return Streams.skipByReading(this, byteCount); }
@Override public void write(int i) throws IOException { Streams.writeSingleByte(this, i); }
public final int readInt() throws IOException { Streams.readFully(in, scratch, 0, SizeOf.INT); return Memory.peekInt(scratch, 0, ByteOrder.BIG_ENDIAN); }
@Override public synchronized int read() throws IOException { return Streams.readSingleByte(this); }
/** * Returns a byte[] containing the remainder of 'in', closing it when done. */ public static byte[] readFully(InputStream in) throws IOException { try { return readFullyNoClose(in); } finally { in.close(); } }
/** * Skips at most {@code n} bytes in this stream. This method does nothing and returns * 0 if {@code n} is negative, but some subclasses may throw. * * <p>Note the "at most" in the description of this method: this method may choose to skip * fewer bytes than requested. Callers should <i>always</i> check the return value. * * <p>This default implementation reads bytes into a temporary * buffer. Concrete subclasses should provide their own implementation. * * @param byteCount the number of bytes to skip. * @return the number of bytes actually skipped. * @throws IOException * if this stream is closed or another IOException occurs. */ public long skip(long byteCount) throws IOException { return Streams.skipByReading(this, byteCount); } }
/** * Writes the single byte to this cipher output stream. * * @param b * the byte to write. * @throws IOException * if an error occurs. */ @Override public void write(int b) throws IOException { Streams.writeSingleByte(this, b); }
public final short readShort() throws IOException { Streams.readFully(in, scratch, 0, SizeOf.SHORT); return Memory.peekShort(scratch, 0, ByteOrder.BIG_ENDIAN); }
@Override public int read() throws IOException { return Streams.readSingleByte(this); }