blob: 634fc927b98bb4236f67223c634b4087da557a1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
package com.github.junrar.unpack.ppm;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* For debugging purposes only.
*
* @author alban
*/
public class AnalyzeHeapDump {
/** Creates a new instance of AnalyzeHeapDump */
public AnalyzeHeapDump() {
}
public static void main(String[] argv) {
File cfile = new File("P:\\test\\heapdumpc");
File jfile = new File("P:\\test\\heapdumpj");
if (!cfile.exists()) {
System.err.println("File not found: " + cfile.getAbsolutePath());
return;
}
if (!jfile.exists()) {
System.err.println("File not found: " + jfile.getAbsolutePath());
return;
}
long clen = cfile.length();
long jlen = jfile.length();
if (clen != jlen) {
System.out.println("File size mismatch");
System.out.println("clen = " + clen);
System.out.println("jlen = " + jlen);
}
// Do byte comparison
long len = Math.min(clen, jlen);
InputStream cin = null;
InputStream jin = null;
int bufferLen = 256*1024;
try {
cin = new BufferedInputStream(
new FileInputStream(cfile), bufferLen);
jin = new BufferedInputStream(
new FileInputStream(jfile), bufferLen);
boolean matching = true;
boolean mismatchFound = false;
long startOff = 0L;
long off = 0L;
while (off < len) {
if (cin.read() != jin.read()) {
if (matching) {
startOff = off;
matching = false;
mismatchFound = true;
}
}
else { // match
if (!matching) {
printMismatch(startOff, off);
matching = true;
}
}
off++;
}
if (!matching) {
printMismatch(startOff, off);
}
if (!mismatchFound) {
System.out.println("Files are identical");
}
System.out.println("Done");
}
catch (IOException e) {
e.printStackTrace();
}
finally {
try {
cin.close();
jin.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
private static void printMismatch(long startOff, long bytesRead) {
System.out.println("Mismatch: off=" + startOff +
"(0x" + Long.toHexString(startOff) +
"), len=" + (bytesRead - startOff));
}
}
|