Class IOUtil

java.lang.Object
com.diozero.util.IOUtil

public class IOUtil
extends Object
  • Constructor Summary

    Constructors
    Constructor Description
    IOUtil()  
  • Method Summary

    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • IOUtil

      public IOUtil()
  • Method Details

    • 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 from
      buffer - 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 from
      buffer - the buffer to read into; the length of the buffer specifies the number of bytes to read
      Throws:
      IOException - if a read error occurs
      EOFException - if unable to read buffer.length bytes