Class FileCompare

java.lang.Object
org.apache.fop.tools.anttasks.FileCompare

public class FileCompare extends Object
This class is an extension of Ant, a script utility from http://ant.apache.org. It provides methods to compare two files.
  • Field Details

    • referenceDirectory

      private String referenceDirectory
    • testDirectory

      private String testDirectory
    • filenameList

      private String[] filenameList
  • Constructor Details

    • FileCompare

      public FileCompare()
  • Method Details

    • setTestDirectory

      public void setTestDirectory(String testDirectory)
      Sets directory for test files.
      Parameters:
      testDirectory - the test directory
    • setReferenceDirectory

      public void setReferenceDirectory(String referenceDirectory)
      Sets directory for reference files.
      Parameters:
      referenceDirectory - the reference directory
    • setFilenames

      public void setFilenames(String filenames)
      Sets the comma-separated list of files to process.
      Parameters:
      filenames - list of files, comma-separated
    • compareFiles

      public static boolean compareFiles(File f1, File f2) throws IOException
      Compares two files to see if they are equal
      Parameters:
      f1 - first file to compare
      f2 - second file to compare
      Returns:
      true if files are same, false otherwise
      Throws:
      IOException - if not caught
    • compareBytes

      private static boolean compareBytes(File file1, File file2) throws IOException
      Compare the contents of two files.
      Parameters:
      file1 - the first file to compare
      file2 - the second file to compare
      Returns:
      true if files are same byte-by-byte, false otherwise
      Throws:
      IOException
    • compareFileSize

      private static boolean compareFileSize(File oldFile, File newFile)
      Does a file size compare of two files
      Parameters:
      oldFile - the first file to compare
      newFile - the second file to compare
      Returns:
      true if files are same length, false otherwise
    • filesExist

      private boolean filesExist(File oldFile, File newFile)
    • writeHeader

      private void writeHeader(PrintWriter results)
    • execute

      public void execute() throws org.apache.tools.ant.BuildException
      Main method of task compare
      Throws:
      org.apache.tools.ant.BuildException - If the execution fails.