private boolean compareFiles(String name1, String name2) { File file1 = new File(System.getProperty("root"), name1); File file2 = new File(System.getProperty("root"), name2); try { if (!file1.exists() || !file2.exists()) { System.out.println("One or both files do not exist:" + name1 + ", " + name2); return false; } if (file1.length() != file2.length()) { System.out.println("File size mismatch:" + name1 + "(" + file1.length() + "), " + name2 + "(" + file2.length() + ")"); return false; } // byte - byte compare byte[] buffer1 = new byte[BUF_SIZE]; byte[] buffer2 = new byte[BUF_SIZE]; FileInputStream fis1 = new FileInputStream(file1); FileInputStream fis2 = new FileInputStream(file2); int index = 0; int read = 0; while ((read = fis1.read(buffer1)) != -1) { fis2.read(buffer2); for (int i = 0; i < read; ++i, ++index) { if (buffer1[i] != buffer2[i]) { System.out.println("Bytes mismatch:" + name1 + ", " + name2 + " at byte " + index); return false; } } } return true; } catch (IOException e) { System.out.println("IOException comparing files: " + name1 + ", " + name2); return false;
private boolean compareFiles(String name1, String name2) { File file1 = new File(System.getProperty("root"), name1); File file2 = new File(System.getProperty("root"), name2); try { if (!file1.exists() || !file2.exists()) { System.out.println("One or both files do not exist:" + name1 + ", " + name2); return false; } if (file1.length() != file2.length()) { System.out.println("File size mismatch:" + name1 + "(" + file1.length() + "), " + name2 + "(" + file2.length() + ")"); return false; } // byte - byte compare byte[] buffer1 = new byte[BUF_SIZE]; byte[] buffer2 = new byte[BUF_SIZE]; FileInputStream fis1 = new FileInputStream(file1); FileInputStream fis2 = new FileInputStream(file2); int index = 0; int read = 0; while ((read = fis1.read(buffer1)) != -1) { fis2.read(buffer2); for (int i = 0; i < read; ++i, ++index) { if (buffer1[i] != buffer2[i]) { System.out.println("Bytes mismatch:" + name1 + ", " + name2 + " at byte " + index); return false; } } } return true; } catch (IOException e) { System.out.println("IOException comparing files: " + name1 + ", " + name2); return false;
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
private boolean compareFiles(String name1, String name2) {
1
private boolean compareFiles(String name1, String name2) {
2
        File file1 = new File(System.getProperty("root"), name1);
2
        File file1 = new File(System.getProperty("root"), name1);
3
        File file2 = new File(System.getProperty("root"), name2);
3
        File file2 = new File(System.getProperty("root"), name2);
4
        try {
4
        try {
5
            if (!file1.exists() || !file2.exists()) {
5
            if (!file1.exists() || !file2.exists()) {
6
                System.out.println("One or both files do not exist:" + name1 + ", " + name2);
6
                System.out.println("One or both files do not exist:" + name1 + ", " + name2);
7
                return false;
7
                return false;
8
            }
8
            }
9
            if (file1.length() != file2.length()) {
9
            if (file1.length() != file2.length()) {
10
                System.out.println("File size mismatch:" + name1 + "(" + file1.length() + "), " +
10
                System.out.println("File size mismatch:" + name1 + "(" + file1.length() + "), " +
11
                                   name2  + "(" + file2.length() + ")");
11
                                   name2  + "(" + file2.length() + ")");
12
                return false;
12
                return false;
13
            }
13
            }
14
            // byte - byte compare
14
            // byte - byte compare
15
            byte[] buffer1 = new byte[BUF_SIZE];
15
            byte[] buffer1 = new byte[BUF_SIZE];
16
            byte[] buffer2 = new byte[BUF_SIZE];
16
            byte[] buffer2 = new byte[BUF_SIZE];
17
            FileInputStream fis1 = new FileInputStream(file1);
17
            FileInputStream fis1 = new FileInputStream(file1);
18
            FileInputStream fis2 = new FileInputStream(file2);
18
            FileInputStream fis2 = new FileInputStream(file2);
19
            int index = 0;
19
            int index = 0;
20
            int read = 0;
20
            int read = 0;
21
            while ((read = fis1.read(buffer1)) != -1) {
21
            while ((read = fis1.read(buffer1)) != -1) {
22
                fis2.read(buffer2);
22
                fis2.read(buffer2);
23
                for (int i = 0; i < read; ++i, ++index) {
23
                for (int i = 0; i < read; ++i, ++index) {
24
                    if (buffer1[i] != buffer2[i]) {
24
                    if (buffer1[i] != buffer2[i]) {
25
                        System.out.println("Bytes mismatch:" + name1 + ", " + name2 +
25
                        System.out.println("Bytes mismatch:" + name1 + ", " + name2 +
26
                                           " at byte " + index);
26
                                           " at byte " + index);
27
                        return false;
27
                        return false;
28
                    }
28
                    }
29
                }
29
                }
30
            }
30
            }
31
            return true;
31
            return true;
32
        }
32
        }
33
        catch (IOException e) {
33
        catch (IOException e) {
34
            System.out.println("IOException comparing files: " + name1 + ", " + name2);
34
            System.out.println("IOException comparing files: " + name1 + ", " + name2);
35
            return false;
35
            return false;
36
        
36
        
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0