Class FileUtils

java.lang.Object
gmbh.pagina.tools.gradle.mac_app.FileUtils

public class FileUtils extends Object
Tools for file interactions.

All methods in this class are static methods. No need to set up any FileUtils object.

  • Method Details

    • copyToDir

      public static void copyToDir(File input, File output)
      Copy an input file to a destination directory, keeping the name.
      Parameters:
      input - The input file to copy.
      output - The directory it is copied into.
    • copyToFile

      public static void copyToFile(File input, File output)
      Copy an input file to a target, possibly renaming it along the way.
      Parameters:
      input - The input file to copy.
      output - The file it will be after copying.
    • copyDir

      public static void copyDir(File input, File output) throws IOException
      Copy a directory to a target directory.
      Parameters:
      input - The input directory to copy.
      output - The directory it will be after copying.
      Throws:
      IOException - If file writing goes wrong.
    • unzip

      public static void unzip(File zipFile, File unzippedFile)
      Unzip an input file to a target.
      Parameters:
      zipFile - The input file to copy.
      unzippedFile - The file once unzipped.
    • zip

      public static void zip(File unzippedFile, File zipFile)
      Zips a file or directory to a target.
      Parameters:
      unzippedFile - The input file to zip.
      zipFile - The file once zipped.
    • tarGz

      public static void tarGz(File infile, File outfile)
      Creates a tar.gz archive.
      Parameters:
      infile - The input file to archive.
      outfile - The file once archived.
    • writeToFile

      public static void writeToFile(File file, String content) throws IOException
      Write a string to a text file that does not yet need to exist.
      Parameters:
      file - Target file.
      content - Text content to write.
      Throws:
      IOException - If the file cannot be created or written.
    • setExecutable

      public static void setExecutable(File file)
      Mark a file as executable. Only works on UNIX-like systems.
      Parameters:
      file - file to mark executable
    • deleteRecursively

      public static void deleteRecursively(File file)
      Delete a file or directory recursively.
      Parameters:
      file - file or directory to delete