InputStreamReader reader = new InputStreamReader(new FileInputStream(temporaryFileName), "UTF8"); for (int length = reader.read(outputchars, 0, outputchars.length); length > 0; length = reader.read( outputchars, 0, outputchars.length)) { os.write(outputchars, 0, length); count += length; if (count > flushThreshold) { os.flush(); count = 0; } } reader.close(); new File(temporaryFileName).delete();
InputStream inputStream = new FileInputStream(temporaryFileName); for (int length = inputStream.read(outputbytes, 0, outputbytes.length); length > 0; length = inputStream.read( outputbytes, 0, outputbytes.length)) { os.write(outputbytes, 0, length); count += length; if (count > flushThreshold) { os.flush(); count = 0; } } inputStream.close(); new File(temporaryFileName).delete();
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xmi/impl/StringSegment.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xmi/impl/StringSegment.java
Method name: void write(Writer, int) Method name: void writeAscii(OutputStream, int)
Number of AST nodes: 9 Number of AST nodes: 9
1
InputStreamReader reader = new InputStreamReader(new FileInputStream(temporaryFileName), "UTF8");
1
InputStream inputStream = new FileInputStream(temporaryFileName);
2
      for (int length = reader.read(outputchars, 0, outputchars.length); length > 0; length = reader.read(
2
      for (int length = inputStream.read(outputbytes, 0, outputbytes.length); length > 0; length = inputStream.read(
3
        outputchars,
3
        outputbytes,
4
        0,
4
        0,
5
        outputchars.length))
5
        outputbytes.length))
6
      {
6
      {
7
        os.write(outputchars, 0, length);
7
        os.write(outputbytes, 0, length);
8
        count += length;
8
        count += length;
9
        if (count > flushThreshold)
9
        if (count > flushThreshold)
10
        {
10
        {
11
          os.flush();
11
          os.flush();
12
          count = 0;
12
          count = 0;
13
        }
13
        }
14
      }
14
      }
15
      reader.close();
15
      inputStream.close();
16
      new File(temporaryFileName).delete();
16
      new File(temporaryFileName).delete();
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are declared in the same class
Number of node comparisons33
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    24
    InputStreamReader reader = new InputStreamReader(new FileInputStream(temporaryFileName), "UTF8");
                                                                                                                                                                                                        
                                                                                                                                          
    31
    InputStream inputStream = new FileInputStream(temporaryFileName);
    25
    for (int length = reader.read(outputchars, 0, outputchars.length); length > 0; length = reader.read(outputchars, 0, outputchars.length))
    25
    for (int length = reader.read(outputchars, 0, outputchars.length); length > 0; length = reader.read(outputchars, 0, outputchars.length))
    32
    for (int length = inputStream.read(outputbytes, 0, outputbytes.length); length > 0; length = inputStream.read(outputbytes, 0, outputbytes.length))
    Differences
    Expression1Expression2Difference
    outputcharsoutputbytesVARIABLE_NAME_MISMATCH
    char[]byte[]VARIABLE_TYPE_MISMATCH
    readerinputStreamVARIABLE_NAME_MISMATCH
    java.io.InputStreamReaderjava.io.InputStreamVARIABLE_TYPE_MISMATCH
    outputcharsoutputbytesVARIABLE_NAME_MISMATCH
    char[]byte[]VARIABLE_TYPE_MISMATCH
    readerinputStreamVARIABLE_NAME_MISMATCH
    java.io.InputStreamReaderjava.io.InputStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type char[] of variable outputchars does not match with type byte[] of variable outputbytes
    • Make classes char[] and byte[] extend a common superclass
    Type java.io.InputStreamReader of variable reader does not match with type java.io.InputStream of variable inputStream
    • Make classes java.io.InputStreamReader and java.io.InputStream extend a common superclass
    Type char[] of variable outputchars does not match with type byte[] of variable outputbytes
    • Make classes char[] and byte[] extend a common superclass
    Type java.io.InputStreamReader of variable reader does not match with type java.io.InputStream of variable inputStream
    • Make classes java.io.InputStreamReader and java.io.InputStream extend a common superclass
    32
    for (int length = inputStream.read(outputbytes, 0, outputbytes.length); length > 0; length = inputStream.read(outputbytes, 0, outputbytes.length))
    26
    os.write(outputchars, 0, length);
    26
    os.write(outputchars, 0, length);
    33
    os.write(outputbytes, 0, length);
    Differences
    Expression1Expression2Difference
    outputcharsoutputbytesVARIABLE_NAME_MISMATCH
    char[]byte[]VARIABLE_TYPE_MISMATCH
    java.io.Writerjava.io.OutputStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type char[] of variable outputchars does not match with type byte[] of variable outputbytes
    • Make classes char[] and byte[] extend a common superclass
    Type java.io.Writer of variable os does not match with type java.io.OutputStream of variable os
    • Make classes java.io.Writer and java.io.OutputStream extend a common superclass
    33
    os.write(outputbytes, 0, length);
    27
    count += length;
    34
    count += length;
    28
    if (count > flushThreshold)
    35
    if (count > flushThreshold)
    29
    os.flush();
    29
    os.flush();
    36
    os.flush();
    Differences
    Expression1Expression2Difference
    java.io.Writerjava.io.OutputStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.Writer of variable os does not match with type java.io.OutputStream of variable os
    • Make classes java.io.Writer and java.io.OutputStream extend a common superclass
    36
    os.flush();
    30
    count = 0;
    37
    count = 0;
    31
    reader.close();
    31
    reader.close();
    38
    inputStream.close();
    Differences
    Expression1Expression2Difference
    readerinputStreamVARIABLE_NAME_MISMATCH
    java.io.InputStreamReaderjava.io.InputStreamVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.InputStreamReader of variable reader does not match with type java.io.InputStream of variable inputStream
    • Make classes java.io.InputStreamReader and java.io.InputStream extend a common superclass
    38
    inputStream.close();
    32
    new File(temporaryFileName).delete();
    39
    new File(temporaryFileName).delete();
    Precondition Violations (8)
    Row Violation
    1Type char[] of variable outputchars does not match with type byte[] of variable outputbytes
    2Type java.io.InputStreamReader of variable reader does not match with type java.io.InputStream of variable inputStream
    3Type char[] of variable outputchars does not match with type byte[] of variable outputbytes
    4Type java.io.InputStreamReader of variable reader does not match with type java.io.InputStream of variable inputStream
    5Type char[] of variable outputchars does not match with type byte[] of variable outputbytes
    6Type java.io.Writer of variable os does not match with type java.io.OutputStream of variable os
    7Type java.io.Writer of variable os does not match with type java.io.OutputStream of variable os
    8Type java.io.InputStreamReader of variable reader does not match with type java.io.InputStream of variable inputStream