Class IOUtils


  • public final class IOUtils
    extends Object
    Utilities for working with IO streams.
    • Method Detail

      • closeQuietly

        public static void closeQuietly​(Reader aReader)
        Closes a reader, catching and logging any exceptions.
        Parameters:
        aReader - A supplied reader to close
      • closeQuietly

        public static void closeQuietly​(Writer aWriter)
        Closes a writer, catching and logging any exceptions.
        Parameters:
        aWriter - A supplied writer to close
      • closeQuietly

        public static void closeQuietly​(InputStream aInputStream)
        Closes an input stream, catching and logging any exceptions.
        Parameters:
        aInputStream - A supplied input stream to close
      • closeQuietly

        public static void closeQuietly​(ImageInputStream aImageInputStream)
        Closes an image input stream, catching and logging any exceptions
        Parameters:
        aImageInputStream - A supplied image input stream to close
      • closeQuietly

        public static void closeQuietly​(ImageOutputStream aImageOutputStream)
        Closes an image output stream, catching and logging any exceptions.
        Parameters:
        aImageOutputStream - A supplied image output stream to close
      • closeQuietly

        public static void closeQuietly​(OutputStream aOutputStream)
        Closes an output stream, catching and logging any exceptions.
        Parameters:
        aOutputStream - A supplied output stream to close
      • closeQuietly

        public static void closeQuietly​(JarFile aJarFile)
        Closes a JarFile, catching and logging any exceptions.
        Parameters:
        aJarFile - A supplied JarFile to close
      • copyStream

        public static void copyStream​(InputStream aInStream,
                                      OutputStream aOutStream)
                               throws IOException
        Writes from an input stream to an output stream; you're responsible for closing the InputStream and OutputStream.
        Parameters:
        aInStream - The stream from which to read
        aOutStream - The stream from which to write
        Throws:
        IOException - If there is trouble reading or writing
      • copyStream

        public static void copyStream​(File aFile,
                                      OutputStream aOutStream)
                               throws IOException
        Writes a file to an output stream. You're responsible for closing the OutputStream; the input stream is closed for you since just a File was passed in.
        Parameters:
        aFile - A file from which to read
        aOutStream - An output stream to which to write
        Throws:
        IOException - If there is a problem reading or writing
      • readBytes

        public static byte[] readBytes​(InputStream aInputStream)
                                throws IOException
        Reads an InputStream into a byte array.
        Parameters:
        aInputStream - The input stream from which to read
        Returns:
        The array of bytes
        Throws:
        IOException - If there is trouble reading from the input stream