Class FileUtils


  • public class FileUtils
    extends FileUtilsV2_2
    This class adds some convenience methods on top of Apache CommonsIO FileUtils. It exists so that the class it extends can contain code only from Apache Commons IO, which simplifies upgrades.
    • Constructor Detail

      • FileUtils

        public FileUtils()
        Instances should NOT be constructed in standard programming.
    • Method Detail

      • copy

        public static void copy​(java.io.File file,
                                java.io.OutputStream out)
                         throws java.io.IOException
        Copies the given file into an output stream.
        Parameters:
        file - input file (must exist).
        out - output stream.
        Throws:
        java.io.IOException - if file is not found or copying fails
      • copy

        public static void copy​(java.io.InputStream in,
                                java.io.File file)
                         throws java.io.IOException
        Copies the given input stream into a file.

        The target file must not be a directory and its parent must exist.

        Parameters:
        in - source stream.
        file - output file to be created or overwritten.
        Throws:
        java.io.IOException - if file is not found or copying fails
      • getTempFileFor

        public static java.io.File getTempFileFor​(java.io.File file)
        Find a non-existing file in the same directory using the same name as prefix.
        Parameters:
        file - file used for the name and location (it is not read or written).
        Returns:
        a non-existing file in the same directory using the same name as prefix.