int fileSize = inStream.available(); byte[] buf = new byte[fileSize]; int count = inStream.read(buf); if (count != fileSize) throw new IOException( "Could read only "+ count + " bytes from a total file size of " + fileSize + ". Import failed."); // Convert bytes to Bytes Byte[] bBytes = new Byte[count]; for (int i=0; i<count; i++) { bBytes[i] = Byte.valueOf(buf[i]); } // return the text converted from the file return BinaryDisplayConverter.convertToString(bBytes, BinaryDisplayConverter.HEX, false);
int fileSize = inStream.available(); byte[] buf = new byte[fileSize]; int count = inStream.read(buf); if (count != fileSize) { throw new IOException( "Could read only "+ count + " bytes from a total file size of " + fileSize + ". Import failed."); } // Convert bytes to Bytes Byte[] bBytes = new Byte[count]; for (int i=0; i<count; i++) { bBytes[i] = Byte.valueOf(buf[i]); } // return the text converted from the file return BinaryDisplayConverter.convertToString(bBytes, BinaryDisplayConverter.HEX, false);
Clone fragments detected by clone detection tool
File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBinary.java File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBlob.java
Method name: String importObject(FileInputStream) Method name: String importObject(FileInputStream)
Number of AST nodes: 9 Number of AST nodes: 9
1
int fileSize = inStream.available();
1
int fileSize = inStream.available();
2
	 	
3
	 	byte[] buf = new byte[fileSize];
2
		byte[] buf = new byte[fileSize];
4
	 	
5
	 	int count = inStream.read(buf);
3
		int count = inStream.read(buf);
6
	 	
7
	 	if (count != fileSize)
4
		if (count != fileSize) {
8
	 		throw new IOException(
5
			throw new IOException(
9
	 			"Could read only "+ count +
6
				"Could read only "+ count +
10
	 			" bytes from a total file size of " + fileSize +
7
				" bytes from a total file size of " + fileSize +
11
	 			". Import failed.");
8
				". Import failed.");
12
	 	
9
		}
13
	 	// Convert bytes to Bytes
10
		// Convert bytes to Bytes
14
	 	Byte[] bBytes = new Byte[count];
11
		Byte[] bBytes = new Byte[count];
15
	 	for (int i=0; i<count; i++) {
12
		for (int i=0; i<count; i++) {
16
	 		bBytes[i] = Byte.valueOf(buf[i]);
13
			bBytes[i] = Byte.valueOf(buf[i]);
17
        }
18
	 
14
		}
19
	// return the text converted from the file 
15
		// return the text converted from the file 
20
	 	return BinaryDisplayConverter.convertToString(bBytes,
16
		return BinaryDisplayConverter.convertToString(bBytes,
21
	 		BinaryDisplayConverter.HEX, false);
17
			BinaryDisplayConverter.HEX, false);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.7
Clones locationClones are in different classes having the same super class
Number of node comparisons35
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)3.1
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    1
    int fileSize = inStream.available();
    1
    int fileSize = inStream.available();
    2
    byte[] buf = new byte[fileSize];
    2
    byte[] buf = new byte[fileSize];
    3
    int count = inStream.read(buf);
    3
    int count = inStream.read(buf);
    4
    if (count != fileSize)
    4
    if (count != fileSize)
    5
    throw new IOException("Could read only " + count + " bytes from a total file size of " + fileSize + ". Import failed.");
    5
    throw new IOException("Could read only " + count + " bytes from a total file size of " + fileSize + ". Import failed.");
    6
    Byte[] bBytes = new Byte[count];
    6
    Byte[] bBytes = new Byte[count];
    7
    for (int i = 0; i < count; i++)
    7
    for (int i = 0; i < count; i++)
    8
    bBytes[i] = Byte.valueOf(buf[i]);
    8
    bBytes[i] = Byte.valueOf(buf[i]);
    9
    return BinaryDisplayConverter.convertToString(bBytes, BinaryDisplayConverter.HEX, false);
    9
    return BinaryDisplayConverter.convertToString(bBytes, BinaryDisplayConverter.HEX, false);
    Precondition Violations (0)
    Row Violation