Class FileUtils

java.lang.Object
org.zeroturnaround.zip.commons.FileUtilsV2_2
org.zeroturnaround.zip.commons.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 Details

    • FileUtils

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

    • copy

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

      public static void copy(InputStream in, File file) throws 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:
      IOException - if file is not found or copying fails
    • getTempFileFor

      public static File getTempFileFor(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.