Class IOUtil


  • public class IOUtil
    extends Object
    • Constructor Detail

      • IOUtil

        public IOUtil()
    • 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 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