Class StreamUtils


  • public final class StreamUtils
    extends Object
    Stream Utilities.
    Author:
    tfennelly
    • Method Detail

      • readStream

        public static byte[] readStream​(InputStream stream)
                                 throws IOException
        Read the supplied InputStream and return as a byte array.
        Parameters:
        stream - The stream to read.
        Returns:
        byte array containing the Stream data.
        Throws:
        IOException - Exception reading from the stream.
      • readStreamAsString

        public static String readStreamAsString​(InputStream stream,
                                                String encoding)
                                         throws IOException
        Read the supplied InputStream and return as a byte array.
        Parameters:
        stream - The stream to read.
        encoding - The encoding to use.
        Returns:
        A String containing the Stream data.
        Throws:
        IOException - Exception reading from the stream.