Class StreamDrainer


  • @Enhance
    public class StreamDrainer
    extends Object
    A utility for draining the contents of an InputStream into a byte array.
    • 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​(InputStream inputStream)
                     throws 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:
        IOException - If the stream reading causes an error.