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;
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
try {
1
try {
2
            if (!file1.exists() || !file2.exists()) {
2
            if (!file1.exists() || !file2.exists()) {
3
                System.out.println("One or both files do not exist:" + name1 + ", " + name2);
3
                System.out.println("One or both files do not exist:" + name1 + ", " + name2);
4
                return false;
4
                return false;
5
            }
5
            }
6
            if (file1.length() != file2.length()) {
6
            if (file1.length() != file2.length()) {
7
                System.out.println("File size mismatch:" + name1 + "(" + file1.length() + "), " +
7
                System.out.println("File size mismatch:" + name1 + "(" + file1.length() + "), " +
8
                                   name2  + "(" + file2.length() + ")");
8
                                   name2  + "(" + file2.length() + ")");
9
                return false;
9
                return false;
10
            }
10
            }
11
            // byte - byte compare
11
            // byte - byte compare
12
            byte[] buffer1 = new byte[BUF_SIZE];
12
            byte[] buffer1 = new byte[BUF_SIZE];
13
            byte[] buffer2 = new byte[BUF_SIZE];
13
            byte[] buffer2 = new byte[BUF_SIZE];
14
            FileInputStream fis1 = new FileInputStream(file1);
14
            FileInputStream fis1 = new FileInputStream(file1);
15
            FileInputStream fis2 = new FileInputStream(file2);
15
            FileInputStream fis2 = new FileInputStream(file2);
16
            int index = 0;
16
            int index = 0;
17
            int read = 0;
17
            int read = 0;
18
            while ((read = fis1.read(buffer1)) != -1) {
18
            while ((read = fis1.read(buffer1)) != -1) {
19
                fis2.read(buffer2);
19
                fis2.read(buffer2);
20
                for (int i = 0; i < read; ++i, ++index) {
20
                for (int i = 0; i < read; ++i, ++index) {
21
                    if (buffer1[i] != buffer2[i]) {
21
                    if (buffer1[i] != buffer2[i]) {
22
                        System.out.println("Bytes mismatch:" + name1 + ", " + name2 +
22
                        System.out.println("Bytes mismatch:" + name1 + ", " + name2 +
23
                                           " at byte " + index);
23
                                           " at byte " + index);
24
                        return false;
24
                        return false;
25
                    }
25
                    }
26
                }
26
                }
27
            }
27
            }
28
            return true;
28
            return true;
29
        }
29
        }
30
        catch (IOException e) {
30
        catch (IOException e) {
31
            System.out.println("IOException comparing files: " + name1 + ", " + name2);
31
            System.out.println("IOException comparing files: " + name1 + ", " + name2);
32
            return false;
32
            return false;
33
        
33
        
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