@Test public void testDecrunch() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); BmdDecruncher.decrunch(new FileInputStream("../test_files/decrunch_test_in.bmd"), out, Collections.<String>emptyList()); verify(new FileInputStream("../test_files/decrunch_test_out.hprof"), new ByteArrayInputStream(out.toByteArray())); }
public static void decrunch(@Nonnull InputStream in, @Nonnull OutputStream out, @Nonnull Collection<String> additionalFiles) throws IOException { Set<String> strings = new HashSet<String>(); for (String file : additionalFiles) { if (file.endsWith(".dex") || file.endsWith(".apk")) { strings.addAll(ApkStringReader.readStrings(new File(file))); } else if (file.endsWith(".jar")) { strings.addAll(JarStringReader.readStrings(new File(file))); } else { throw new IllegalArgumentException("Invalid string input file: " + file); } } if (!(out instanceof BufferedOutputStream)) { out = new BufferedOutputStream(out); } if (!(in instanceof BufferedInputStream)) { in = new BufferedInputStream(in); } try { DecrunchProcessor processor = new DecrunchProcessor(out, strings); BmdReader reader = new BmdReader(in, processor); while (reader.hasNext()) { reader.next(); } processor.writeHeapRecords(); out.flush(); } finally { out.close(); } }
BmdDecruncher { public static void decrunch(@Nonnull InputStream in, @Nonnull OutputStream out, @Nonnull Collection<String> additionalFiles) throws IOException { Set<String> strings = new HashSet<String>(); for (String file : additionalFiles) { if (file.endsWith(".dex") || file.endsWith(".apk")) { strings.addAll(ApkStringReader.readStrings(new File(file))); } else if (file.endsWith(".jar")) { strings.addAll(JarStringReader.readStrings(new File(file))); } else { throw new IllegalArgumentException("Invalid string input file: " + file); } } if (!(out instanceof BufferedOutputStream)) { out = new BufferedOutputStream(out); } if (!(in instanceof BufferedInputStream)) { in = new BufferedInputStream(in); } try { DecrunchProcessor processor = new DecrunchProcessor(out, strings); BmdReader reader = new BmdReader(in, processor); while (reader.hasNext()) { reader.next(); } processor.writeHeapRecords(); out.flush(); } finally { out.close(); } } }
BmdDecruncher { public static void decrunch(@Nonnull InputStream in, @Nonnull OutputStream out, @Nonnull Collection<String> additionalFiles) throws IOException { Set<String> strings = new HashSet<String>(); for (String file : additionalFiles) { if (file.endsWith(".dex") || file.endsWith(".apk")) { strings.addAll(ApkStringReader.readStrings(new File(file))); } else if (file.endsWith(".jar")) { strings.addAll(JarStringReader.readStrings(new File(file))); } else { throw new IllegalArgumentException("Invalid string input file: " + file); } } if (!(out instanceof BufferedOutputStream)) { out = new BufferedOutputStream(out); } if (!(in instanceof BufferedInputStream)) { in = new BufferedInputStream(in); } try { DecrunchProcessor processor = new DecrunchProcessor(out, strings); BmdReader reader = new BmdReader(in, processor); while (reader.hasNext()) { reader.next(); } processor.writeHeapRecords(); out.flush(); } finally { out.close(); } }  }
BmdDecruncher { public static void decrunch(@Nonnull InputStream in, @Nonnull OutputStream out, @Nonnull Collection<String> additionalFiles) throws IOException { Set<String> strings = new HashSet<String>(); for (String file : additionalFiles) { if (file.endsWith(".dex") || file.endsWith(".apk")) { strings.addAll(ApkStringReader.readStrings(new File(file))); } else if (file.endsWith(".jar")) { strings.addAll(JarStringReader.readStrings(new File(file))); } else { throw new IllegalArgumentException("Invalid string input file: " + file); } } if (!(out instanceof BufferedOutputStream)) { out = new BufferedOutputStream(out); } if (!(in instanceof BufferedInputStream)) { in = new BufferedInputStream(in); } try { DecrunchProcessor processor = new DecrunchProcessor(out, strings); BmdReader reader = new BmdReader(in, processor); while (reader.hasNext()) { reader.next(); } processor.writeHeapRecords(); out.flush(); } finally { out.close(); } }  static void decrunch(@Nonnull InputStream in, @Nonnull OutputStream out, @Nonnull Collection<String> additionalFiles); static void main(String[] args); }
BmdDecruncher { public static void decrunch(@Nonnull InputStream in, @Nonnull OutputStream out, @Nonnull Collection<String> additionalFiles) throws IOException { Set<String> strings = new HashSet<String>(); for (String file : additionalFiles) { if (file.endsWith(".dex") || file.endsWith(".apk")) { strings.addAll(ApkStringReader.readStrings(new File(file))); } else if (file.endsWith(".jar")) { strings.addAll(JarStringReader.readStrings(new File(file))); } else { throw new IllegalArgumentException("Invalid string input file: " + file); } } if (!(out instanceof BufferedOutputStream)) { out = new BufferedOutputStream(out); } if (!(in instanceof BufferedInputStream)) { in = new BufferedInputStream(in); } try { DecrunchProcessor processor = new DecrunchProcessor(out, strings); BmdReader reader = new BmdReader(in, processor); while (reader.hasNext()) { reader.next(); } processor.writeHeapRecords(); out.flush(); } finally { out.close(); } }  static void decrunch(@Nonnull InputStream in, @Nonnull OutputStream out, @Nonnull Collection<String> additionalFiles); static void main(String[] args);  }