summaryrefslogtreecommitdiff
path: root/org.fox.ttcomics/src/main/java/org/fox/ttcomics2/junrar/unpack/ppm/AnalyzeHeapDump.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.fox.ttcomics/src/main/java/org/fox/ttcomics2/junrar/unpack/ppm/AnalyzeHeapDump.java')
-rw-r--r--org.fox.ttcomics/src/main/java/org/fox/ttcomics2/junrar/unpack/ppm/AnalyzeHeapDump.java85
1 files changed, 85 insertions, 0 deletions
diff --git a/org.fox.ttcomics/src/main/java/org/fox/ttcomics2/junrar/unpack/ppm/AnalyzeHeapDump.java b/org.fox.ttcomics/src/main/java/org/fox/ttcomics2/junrar/unpack/ppm/AnalyzeHeapDump.java
new file mode 100644
index 0000000..9ba997d
--- /dev/null
+++ b/org.fox.ttcomics/src/main/java/org/fox/ttcomics2/junrar/unpack/ppm/AnalyzeHeapDump.java
@@ -0,0 +1,85 @@
+package org.fox.ttcomics2.junrar.unpack.ppm;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class 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));
+ }
+}