FileDocCategorySizeDatePackage
FilesMatch.javaAPI DocApache Ant 1.702775Wed Dec 13 06:16:18 GMT 2006None

FilesMatch

public class FilesMatch extends Object implements Condition
Compares two files for equality based on size and content. Timestamps are not at all looked at.
since
Ant 1.5

Fields Summary
private static final org.apache.tools.ant.util.FileUtils
FILE_UTILS
Helper that provides the file comparison method.
private File
file1
files to compare
private File
file2
private boolean
textfile
Constructors Summary
Methods Summary
public booleaneval()
comparison method of the interface

return
true if the files are equal
exception
BuildException if it all went pear-shaped


        //validate
        if (file1 == null || file2 == null) {
            throw new BuildException("both file1 and file2 are required in "
                                     + "filesmatch");
        }

        //#now match the files
        boolean matches = false;
        try {
            matches = FILE_UTILS.contentEquals(file1, file2, textfile);
        } catch (IOException ioe) {
            throw new BuildException("when comparing files: "
                + ioe.getMessage(), ioe);
        }
        return matches;
    
public voidsetFile1(java.io.File file1)
Sets the File1 attribute

param
file1 The new File1 value



                   
        
        this.file1 = file1;
    
public voidsetFile2(java.io.File file2)
Sets the File2 attribute

param
file2 The new File2 value

        this.file2 = file2;
    
public voidsetTextfile(boolean textfile)
Set whether to ignore line endings when comparing files.

param
textfile whether to ignore line endings.

        this.textfile = textfile;