Class IOUtils


  • public class IOUtils
    extends Object
    Input / Output utility methods
    Author:
    osbornb
    • Field Detail

      • COPY_BUFFER_SIZE

        public static int COPY_BUFFER_SIZE
        Copy stream buffer chunk size in bytes
        Since:
        2.0.3
    • Constructor Detail

      • IOUtils

        public IOUtils()
    • Method Detail

      • copyFile

        public static void copyFile​(File copyFrom,
                                    File copyTo)
                             throws IOException
        Copy a file to a file location
        Parameters:
        copyFrom - file to copy
        copyTo - file to copy to
        Throws:
        IOException - upon failure to copy file
      • copyStream

        public static void copyStream​(InputStream copyFrom,
                                      File copyTo)
                               throws IOException
        Copy an input stream to a file location
        Parameters:
        copyFrom - stream to copy
        copyTo - file to copy to
        Throws:
        IOException - upon failure to copy the stream
      • fileBytes

        public static byte[] fileBytes​(File file)
                                throws IOException
        Get the file bytes
        Parameters:
        file - file
        Returns:
        bytes
        Throws:
        IOException - upon failure to read the file
      • streamBytes

        public static byte[] streamBytes​(InputStream stream)
                                  throws IOException
        Get the stream bytes
        Parameters:
        stream - input stream
        Returns:
        bytes
        Throws:
        IOException - upon failure to read stream bytes
      • copyStream

        public static void copyStream​(InputStream copyFrom,
                                      OutputStream copyTo)
                               throws IOException
        Copy an input stream to an output stream
        Parameters:
        copyFrom - stream to copy
        copyTo - stream to copy to
        Throws:
        IOException - upon failure to copy stream