Class IO


  • public final class IO
    extends java.lang.Object
    IO Utilities.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  IO.SafeFileFilter
      A FileFilter for obtaining a list of contents that does not contain the special . and .. entries that some JVM environments report.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int BUFFER_SIZE  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private IO()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void close​(java.io.Closeable c)
      closes an Closeable, and silently ignores exceptions
      static void copy​(java.io.File from, java.io.File to)
      Copy files or directories.
      static void copy​(java.io.InputStream in, java.io.OutputStream out)
      Copy the entire InputStream to the OutputStream
      static void copy​(java.io.Reader in, java.io.Writer out)
      Copy Reader to Writer out until EOF or exception.
      static void copyDir​(java.io.File from, java.io.File to)
      Copy the contents of a directory from one directory to another.
      static void copyFile​(java.io.File from, java.io.File to)
      Copy a file from one place to another
      static java.lang.String readToString​(java.io.File file)
      Read the contents of a file into a String and return it.
      • Methods inherited from class java.lang.Object

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

      • IO

        private IO()
    • Method Detail

      • copy

        public static void copy​(java.io.Reader in,
                                java.io.Writer out)
                         throws java.io.IOException
        Copy Reader to Writer out until EOF or exception.
        Parameters:
        in - the Reader to read from
        out - the Writer to write to
        Throws:
        java.io.IOException - if unable to copy the contents
      • readToString

        public static java.lang.String readToString​(java.io.File file)
                                             throws java.io.IOException
        Read the contents of a file into a String and return it.
        Parameters:
        file - the file to read.
        Returns:
        the contents of the file.
        Throws:
        java.io.IOException - if unable to read the file.
      • close

        public static void close​(java.io.Closeable c)
        closes an Closeable, and silently ignores exceptions
        Parameters:
        c - the closeable to close
      • copy

        public static void copy​(java.io.File from,
                                java.io.File to)
                         throws java.io.IOException
        Copy files or directories.
        Parameters:
        from - the from path
        to - the destination path
        Throws:
        java.io.IOException - if unable to copy the file
      • copyDir

        public static void copyDir​(java.io.File from,
                                   java.io.File to)
                            throws java.io.IOException
        Copy the contents of a directory from one directory to another.
        Parameters:
        from - the from directory
        to - the destination directory
        Throws:
        java.io.IOException - if unable to copy the file
      • copy

        public static void copy​(java.io.InputStream in,
                                java.io.OutputStream out)
                         throws java.io.IOException
        Copy the entire InputStream to the OutputStream
        Parameters:
        in - the input stream to read from
        out - the output stream to write to
        Throws:
        java.io.IOException - if unable to copy the stream
      • copyFile

        public static void copyFile​(java.io.File from,
                                    java.io.File to)
                             throws java.io.IOException
        Copy a file from one place to another
        Parameters:
        from - the file to copy
        to - the destination file to create
        Throws:
        java.io.IOException - if unable to copy the file