Class IOUtils


  • public class IOUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void closeQuietly​(java.io.Closeable is, org.slf4j.Logger log)
      Closes the given Closeable quietly.
      static byte[] toByteArray​(java.io.InputStream is)
      Reads and returns the rest of the given input stream as a byte array.
      static java.lang.String toString​(java.io.InputStream is)
      Reads and returns the rest of the given input stream as a string.
      • Methods inherited from class java.lang.Object

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

      • toByteArray

        public static byte[] toByteArray​(java.io.InputStream is)
                                  throws java.io.IOException
        Reads and returns the rest of the given input stream as a byte array. It's the caller's responsibility to close the stream after the read.
        Parameters:
        is - an InputStream
        Returns:
        a byte array of all content in the InputStream
        Throws:
        java.io.IOException - If there were any problems reading from the stream
      • toString

        public static java.lang.String toString​(java.io.InputStream is)
                                         throws java.io.IOException
        Reads and returns the rest of the given input stream as a string. It's the caller's responsibility to close the stream after the read.
        Parameters:
        is - an InputStream
        Returns:
        the string from the content of the input stream
        Throws:
        java.io.IOException - If there were any problems reading from the stream
      • closeQuietly

        public static void closeQuietly​(java.io.Closeable is,
                                        org.slf4j.Logger log)
        Closes the given Closeable quietly.
        Parameters:
        is - the given closeable
        log - logger used to log any failure should the close fail