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: boolean compareFiles(String, String)
|
Method name: boolean compareFiles(String, String)
|
|||
Number of AST nodes: 22 | Number of AST nodes: 22 | |||
1 | File file1 = new File(System.getProperty("root"), name1);↵ | 1 | File file1 = new File(System.getProperty("root"), name1);↵ | |
2 | File file2 = new File(System.getProperty("root"), name2);↵ | 2 | File file2 = new File(System.getProperty("root"), name2);↵ | |
3 | try {↵ | 3 | try {↵ | |
4 | if (!file1.exists() || !file2.exists()) {↵ | 4 | if (!file1.exists() || !file2.exists()) {↵ | |
5 | System.out.println("One or both files do not exist:" + name1 + ", " + name2);↵ | 5 | System.out.println("One or both files do not exist:" + name1 + ", " + name2);↵ | |
6 | return false;↵ | 6 | return false;↵ | |
7 | }↵ | 7 | }↵ | |
8 | if (file1.length() != file2.length()) {↵ | 8 | if (file1.length() != file2.length()) {↵ | |
9 | System.out.println("File size mismatch:" + name1 + "(" + file1.length() + "), " +↵ | 9 | System.out.println("File size mismatch:" + name1 + "(" + file1.length() + "), " +↵ | |
10 | name2 + "(" + file2.length() + ")");↵ | 10 | name2 + "(" + file2.length() + ")");↵ | |
11 | return false;↵ | 11 | return false;↵ | |
12 | }↵ | 12 | }↵ | |
13 | // byte - byte compare↵ | 13 | // byte - byte compare↵ | |
14 | byte[] buffer1 = new byte[BUF_SIZE];↵ | 14 | byte[] buffer1 = new byte[BUF_SIZE];↵ | |
15 | byte[] buffer2 = new byte[BUF_SIZE];↵ | 15 | byte[] buffer2 = new byte[BUF_SIZE];↵ | |
16 | FileInputStream fis1 = new FileInputStream(file1);↵ | 16 | FileInputStream fis1 = new FileInputStream(file1);↵ | |
17 | FileInputStream fis2 = new FileInputStream(file2);↵ | 17 | FileInputStream fis2 = new FileInputStream(file2);↵ | |
18 | int index = 0;↵ | 18 | int index = 0;↵ | |
19 | int read = 0;↵ | 19 | int read = 0;↵ | |
20 | while ((read = fis1.read(buffer1)) != -1) {↵ | 20 | while ((read = fis1.read(buffer1)) != -1) {↵ | |
21 | fis2.read(buffer2);↵ | 21 | fis2.read(buffer2);↵ | |
22 | for (int i = 0; i < read; ++i, ++index) {↵ | 22 | for (int i = 0; i < read; ++i, ++index) {↵ | |
23 | if (buffer1[i] != buffer2[i]) {↵ | 23 | if (buffer1[i] != buffer2[i]) {↵ | |
24 | System.out.println("Bytes mismatch:" + name1 + ", " + name2 +↵ | 24 | System.out.println("Bytes mismatch:" + name1 + ", " + name2 +↵ | |
25 | " at byte " + index);↵ | 25 | " at byte " + index);↵ | |
26 | return false;↵ | 26 | return false;↵ | |
27 | }↵ | 27 | }↵ | |
28 | }↵ | 28 | }↵ | |
29 | }↵ | 29 | }↵ | |
30 | return true;↵ | 30 | return true;↵ | |
31 | }↵ | 31 | }↵ | |
32 | catch (IOException e) {↵ | 32 | catch (IOException e) {↵ | |
33 | System.out.println("IOException comparing files: " + name1 + ", " + name2);↵ | 33 | System.out.println("IOException comparing files: " + name1 + ", " + name2);↵ | |
34 | return false;↵ | 34 | return false;↵ | |
35 | } | 35 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 3.1 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 102 |
Number of mapped statements | 22 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 25.0 |
Clone type | Type 1 |
ID | Statement | ID | Statement | |
---|---|---|---|---|
1 | File file1 = new File(System.getProperty("root"), name1); | 1 | File file1 = new File(System.getProperty("root"), name1); | |
2 | File file2 = new File(System.getProperty("root"), name2); | 2 | File file2 = new File(System.getProperty("root"), name2); | |
3 | try | 3 | try | |
4 | if (!file1.exists() || !file2.exists()) | 4 | if (!file1.exists() || !file2.exists()) | |
5 | System.out.println("One or both files do not exist:" + name1 + ", " + name2); | 5 | System.out.println("One or both files do not exist:" + name1 + ", " + name2); | |
6 | return false; | 6 | return false; | |
7 | if (file1.length() != file2.length()) | 7 | if (file1.length() != file2.length()) | |
8 | System.out.println("File size mismatch:" + name1 + "(" + file1.length() + "), " + name2 + "(" + file2.length() + ")"); | 8 | System.out.println("File size mismatch:" + name1 + "(" + file1.length() + "), " + name2 + "(" + file2.length() + ")"); | |
9 | return false; | 9 | return false; | |
10 | byte[] buffer1 = new byte[BUF_SIZE]; | 10 | byte[] buffer1 = new byte[BUF_SIZE]; | |
11 | byte[] buffer2 = new byte[BUF_SIZE]; | 11 | byte[] buffer2 = new byte[BUF_SIZE]; | |
12 | FileInputStream fis1 = new FileInputStream(file1); | 12 | FileInputStream fis1 = new FileInputStream(file1); | |
13 | FileInputStream fis2 = new FileInputStream(file2); | 13 | FileInputStream fis2 = new FileInputStream(file2); | |
14 | int index = 0; | 14 | int index = 0; | |
15 | int read = 0; | 15 | int read = 0; | |
16 | while ((read = fis1.read(buffer1)) != -1) | 16 | while ((read = fis1.read(buffer1)) != -1) | |
17 | fis2.read(buffer2); | 17 | fis2.read(buffer2); | |
18 | for (int i = 0; i < read; ++i, ++index) | 18 | for (int i = 0; i < read; ++i, ++index) | |
19 | if (buffer1[i] != buffer2[i]) | 19 | if (buffer1[i] != buffer2[i]) | |
20 | System.out.println("Bytes mismatch:" + name1 + ", " + name2 + " at byte " + index); | 20 | System.out.println("Bytes mismatch:" + name1 + ", " + name2 + " at byte " + index); | |
21 | return false; | 21 | return false; | |
22 | return true; | 22 | return true; |
Row | Violation |
---|---|
1 | Not all possible execution flows end in a return statement |