Class FileUtils

java.lang.Object
org.eclipse.aether.util.FileUtils

public final class FileUtils extends Object
A utility class to write files.
Since:
1.9.0
  • Method Details

    • newTempFile

      public static FileUtils.TempFile newTempFile() throws IOException
      Creates a FileUtils.TempFile. It will be in the default temporary-file directory. Returned instance should be handled in try-with-resource construct and created temp file is removed on close, if exists.
      Throws:
      IOException
    • newTempFile

      public static FileUtils.TempFile newTempFile(Path file) throws IOException
      Creates a FileUtils.TempFile for given file. It will be in same directory where given file is, and will reuse its name for generated name. Returned instance should be handled in try-with-resource construct and created temp file is removed on close, if exists.
      Throws:
      IOException
    • writeFile

      public static void writeFile(Path target, FileUtils.FileWriter writer) throws IOException
      Writes file without backup.
      Parameters:
      target - that is the target file (must be file, the path must have parent).
      writer - the writer that will accept a Path to write content to.
      Throws:
      IOException - if at any step IO problem occurs.
    • writeFileWithBackup

      public static void writeFileWithBackup(Path target, FileUtils.FileWriter writer) throws IOException
      Writes file with backup copy (appends ".bak" extension).
      Parameters:
      target - that is the target file (must be file, the path must have parent).
      writer - the writer that will accept a Path to write content to.
      Throws:
      IOException - if at any step IO problem occurs.