Class StreamUtils


  • public abstract class StreamUtils
    extends java.lang.Object
    Provides utility methods for input and output streams.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_BUFFER_SIZE
      Default value is 2048.
    • Constructor Summary

      Constructors 
      Constructor Description
      StreamUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void copy​(java.io.InputStream input, java.io.OutputStream output)
      Copies information from the input stream to the output stream using a default buffer size of 2048 bytes.
      static void copy​(java.io.InputStream input, java.io.OutputStream output, int bufferSize)
      Copies information from the input stream to the output stream using the specified buffer size
      static void copyThenClose​(java.io.InputStream input, java.io.OutputStream output)
      Copies information between specified streams and then closes both of the streams.
      static byte[] getBytes​(java.io.InputStream input)  
      • Methods inherited from class java.lang.Object

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

      • DEFAULT_BUFFER_SIZE

        public static final int DEFAULT_BUFFER_SIZE
        Default value is 2048.
        See Also:
        Constant Field Values
    • Constructor Detail

      • StreamUtils

        public StreamUtils()
    • Method Detail

      • copy

        public static void copy​(java.io.InputStream input,
                                java.io.OutputStream output)
                         throws java.io.IOException
        Copies information from the input stream to the output stream using a default buffer size of 2048 bytes.
        Throws:
        java.io.IOException
      • copy

        public static void copy​(java.io.InputStream input,
                                java.io.OutputStream output,
                                int bufferSize)
                         throws java.io.IOException
        Copies information from the input stream to the output stream using the specified buffer size
        Throws:
        java.io.IOException
      • copyThenClose

        public static void copyThenClose​(java.io.InputStream input,
                                         java.io.OutputStream output)
                                  throws java.io.IOException
        Copies information between specified streams and then closes both of the streams.
        Throws:
        java.io.IOException
      • getBytes

        public static byte[] getBytes​(java.io.InputStream input)
                               throws java.io.IOException
        Returns:
        a byte[] containing the information contained in the specified InputStream.
        Throws:
        java.io.IOException