Package org.apache.fop.tools.anttasks
Class FileCompare
- java.lang.Object
-
- org.apache.fop.tools.anttasks.FileCompare
-
public class FileCompare extends java.lang.Object
This class is an extension of Ant, a script utility from http://ant.apache.org. It provides methods to compare two files.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String[]
filenameList
private java.lang.String
referenceDirectory
private java.lang.String
testDirectory
-
Constructor Summary
Constructors Constructor Description FileCompare()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static boolean
compareBytes(java.io.File file1, java.io.File file2)
Compare the contents of two files.static boolean
compareFiles(java.io.File f1, java.io.File f2)
Compares two files to see if they are equalprivate static boolean
compareFileSize(java.io.File oldFile, java.io.File newFile)
Does a file size compare of two filesvoid
execute()
Main method of task compareprivate boolean
filesExist(java.io.File oldFile, java.io.File newFile)
void
setFilenames(java.lang.String filenames)
Sets the comma-separated list of files to process.void
setReferenceDirectory(java.lang.String referenceDirectory)
Sets directory for reference files.void
setTestDirectory(java.lang.String testDirectory)
Sets directory for test files.private void
writeHeader(java.io.PrintWriter results)
-
-
-
Method Detail
-
setTestDirectory
public void setTestDirectory(java.lang.String testDirectory)
Sets directory for test files.- Parameters:
testDirectory
- the test directory
-
setReferenceDirectory
public void setReferenceDirectory(java.lang.String referenceDirectory)
Sets directory for reference files.- Parameters:
referenceDirectory
- the reference directory
-
setFilenames
public void setFilenames(java.lang.String filenames)
Sets the comma-separated list of files to process.- Parameters:
filenames
- list of files, comma-separated
-
compareFiles
public static boolean compareFiles(java.io.File f1, java.io.File f2) throws java.io.IOException
Compares two files to see if they are equal- Parameters:
f1
- first file to comparef2
- second file to compare- Returns:
- true if files are same, false otherwise
- Throws:
java.io.IOException
- if not caught
-
compareBytes
private static boolean compareBytes(java.io.File file1, java.io.File file2) throws java.io.IOException
Compare the contents of two files.- Parameters:
file1
- the first file to comparefile2
- the second file to compare- Returns:
- true if files are same byte-by-byte, false otherwise
- Throws:
java.io.IOException
-
compareFileSize
private static boolean compareFileSize(java.io.File oldFile, java.io.File newFile)
Does a file size compare of two files- Parameters:
oldFile
- the first file to comparenewFile
- the second file to compare- Returns:
- true if files are same length, false otherwise
-
filesExist
private boolean filesExist(java.io.File oldFile, java.io.File newFile)
-
writeHeader
private void writeHeader(java.io.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.
-
-