Class StreamTools


  • public class StreamTools
    extends java.lang.Object
    Utility methods for streams.
    • Constructor Summary

      Constructors 
      Constructor Description
      StreamTools()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int readUntilEnd​(java.io.InputStream in, byte[] buffer, int offset, int length)
      Reads from the stream until either the length number of bytes is read, or the stream ends.
      • Methods inherited from class java.lang.Object

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

      • StreamTools

        public StreamTools()
    • Method Detail

      • readUntilEnd

        public static int readUntilEnd​(java.io.InputStream in,
                                       byte[] buffer,
                                       int offset,
                                       int length)
                                throws java.io.IOException
        Reads from the stream until either the length number of bytes is read, or the stream ends. Note that neither case throws an exception.
        Parameters:
        in - The stream to read from.
        buffer - Buffer to write the data that is read from the stream.
        offset - Offset in the buffer to start writing from.
        length - Maximum number of bytes to read from the stream.
        Returns:
        The number of bytes read from the stream.
        Throws:
        java.io.IOException - On read error.