Class IOUtils


  • public class IOUtils
    extends Object
    Provides utility methods for working with I/O streams. Based on com.google.common.io.* from com.google.guava:17.0
    Author:
    Chris Nokleberg, Colin Decker, Bin Zhu
    • Constructor Detail

      • IOUtils

        public IOUtils()
    • Method Detail

      • copy

        public static long copy​(InputStream from,
                                OutputStream to)
                         throws IOException
        Copies all bytes from the input stream to the output stream. Does not close or flush either stream.
        Parameters:
        from - the input stream to read from
        to - the output stream to write to
        Returns:
        the number of bytes copied
        Throws:
        IOException - if an I/O error occurs
      • toString

        public static String toString​(Readable r)
                               throws IOException
        Reads all characters from a Readable object into a String. Does not close the Readable.
        Parameters:
        r - the object to read from
        Returns:
        a string containing all the characters
        Throws:
        IOException - if an I/O error occurs
      • copy

        public static long copy​(Readable from,
                                Appendable to)
                         throws IOException
        Copies all characters between the Readable and Appendable objects. Does not close or flush either object.
        Parameters:
        from - the object to read from
        to - the object to write to
        Returns:
        the number of characters copied
        Throws:
        IOException - if an I/O error occurs