Class StreamUtil


  • public final class StreamUtil
    extends Object
    Utility class with commonly used stream operations
    Since:
    5.3.5
    • Method Detail

      • inputStreamToArray

        public static byte[] inputStreamToArray​(InputStream is)
                                         throws IOException
        Reads the full content of a stream and returns them in a byte array
        Parameters:
        is - the stream to read
        Returns:
        a byte array containing all of the bytes from the stream
        Throws:
        IOException - if there is a problem reading from the input stream
      • getResourceStream

        public static InputStream getResourceStream​(String key)
        Gets the resource's inputstream.
        Parameters:
        key - the full name of the resource
        Returns:
        the InputStream to get the resource or null if not found
      • getResourceStream

        public static InputStream getResourceStream​(String key,
                                                    ClassLoader loader)
        Gets the resource's inputstream .
        Parameters:
        key - the full name of the resource
        loader - the ClassLoader to load the resource or null to try the ones available
        Returns:
        the InputStream to get the resource or null if not found