Package org.apache.iceberg.io
Class IOUtil
java.lang.Object
org.apache.iceberg.io.IOUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
readFully
(InputStream stream, byte[] bytes, int offset, int length) Reads into a buffer from a stream, making multiple read calls if necessary.static int
readRemaining
(InputStream stream, byte[] bytes, int offset, int length) Reads into a buffer from a stream, making multiple read calls if necessary returning the number of bytes read until end of stream.static void
writeFully
(OutputStream outputStream, ByteBuffer buffer) Writes a buffer into a stream, making multiple write calls if necessary.
-
Method Details
-
readFully
public static void readFully(InputStream stream, byte[] bytes, int offset, int length) throws IOException Reads into a buffer from a stream, making multiple read calls if necessary.- Parameters:
stream
- an InputStream to read frombytes
- a buffer to write intooffset
- starting offset in the buffer for the datalength
- length of bytes to copy from the input stream to the buffer- Throws:
EOFException
- if the end of the stream is reached before reading length bytesIOException
- if there is an error while reading
-
writeFully
Writes a buffer into a stream, making multiple write calls if necessary.- Throws:
IOException
-
readRemaining
public static int readRemaining(InputStream stream, byte[] bytes, int offset, int length) throws IOException Reads into a buffer from a stream, making multiple read calls if necessary returning the number of bytes read until end of stream.- Parameters:
stream
- an InputStream to read frombytes
- a buffer to write intooffset
- starting offset in the buffer for the datalength
- length of bytes to copy from the input stream to the buffer- Returns:
- the number of bytes read
- Throws:
IOException
- if there is an error while reading
-