Class FileUtil

java.lang.Object
org.apache.camel.tooling.util.FileUtil

public final class FileUtil extends Object
  • Method Details

    • updateFile

      public static boolean updateFile(Path path, String newdata) throws IOException
      Update a file with the given string content if neeed. The file won't be modified if the content is already the same.
      Parameters:
      path - the path of the file to update
      newdata - the new string data, null to delete the file
      Returns:
      true if the file was modified, false otherwise
      Throws:
      IOException - if an exception occurs
    • updateFile

      public static boolean updateFile(Path path, String newdata, Charset encoding) throws IOException
      Update a file with the given string content if neeed. The file won't be modified if the content is already the same.
      Parameters:
      path - the path of the file to update
      newdata - the new string data, null to delete the file
      encoding - the encoding to use
      Returns:
      true if the file was modified, false otherwise
      Throws:
      IOException - if an exception occurs
    • updateFile

      public static boolean updateFile(Path path, byte[] newdata) throws IOException
      Update a file with the given binary content if neeed. The file won't be modified if the content is already the same.
      Parameters:
      path - the path of the file to update
      newdata - the new binary data, null to delete the file
      Returns:
      true if the file was modified, false otherwise
      Throws:
      IOException - if an exception occurs
    • updateFile

      public static void updateFile(Path from, Path to) throws IOException
      Read the content of the input file and update the target accordingly
      Parameters:
      from - the source file
      to - the target file
      Throws:
      IOException - if an exception occurs