Package com.diozero.util
Class IOUtil
- java.lang.Object
-
- com.diozero.util.IOUtil
-
public class IOUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description IOUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
read(InputStream is, byte[] buffer)
Attempt to read buffer.length bytes into buffer from the input steam.static void
readFully(InputStream is, byte[] buffer)
Attempt to read buffer.length bytes into buffer from the input steam, throw an exception if unable to read buffer.length bytes.
-
-
-
Method Detail
-
read
public static int read(InputStream is, byte[] buffer) throws IOException
Attempt to read buffer.length bytes into buffer from the input steam. This implementation loops until the buffer is fully populated with data. The number of bytes actually read is returned - it may not equal buffer.length if the end of the input stream is reached.- Parameters:
is
- the input stream to read frombuffer
- the buffer to read into; the length of the buffer specifies the number of bytes to read- Returns:
- the number of bytes actually read, can be less than buffer.length if EOF is reached
- Throws:
IOException
- if a read error occurs
-
readFully
public static void readFully(InputStream is, byte[] buffer) throws IOException, EOFException
Attempt to read buffer.length bytes into buffer from the input steam, throw an exception if unable to read buffer.length bytes.- Parameters:
is
- the input stream to read frombuffer
- the buffer to read into; the length of the buffer specifies the number of bytes to read- Throws:
IOException
- if a read error occursEOFException
- if unable to read buffer.length bytes
-
-