Class StreamDrainer


  • public class StreamDrainer
    extends java.lang.Object
    A utility for draining the contents of an InputStream into a byte array.
    • Constructor Summary

      Constructors 
      Constructor Description
      StreamDrainer()
      Creates a stream drainer with the default buffer size.
      StreamDrainer​(int bufferSize)
      Creates a stream drainer with the given buffer size.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] drain​(java.io.InputStream inputStream)
      Drains an input stream into a byte array.
      • Methods inherited from class java.lang.Object

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

      • StreamDrainer

        public StreamDrainer()
        Creates a stream drainer with the default buffer size.
      • StreamDrainer

        public StreamDrainer​(int bufferSize)
        Creates a stream drainer with the given buffer size.
        Parameters:
        bufferSize - The buffer size for reading from a given stream.
    • Method Detail

      • drain

        public byte[] drain​(java.io.InputStream inputStream)
                     throws java.io.IOException
        Drains an input stream into a byte array. The given input stream is not closed.
        Parameters:
        inputStream - The input stream to drain.
        Returns:
        A byte array containing the content of the input stream.
        Throws:
        java.io.IOException - If the stream reading causes an error.