gpt4 book ai didi

com.googlecode.d2j.reader.zip.ZipUtil类的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 01:15:31 26 4
gpt4 key购买 nike

本文整理了Java中com.googlecode.d2j.reader.zip.ZipUtil类的一些代码示例,展示了ZipUtil类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipUtil类的具体详情如下:
包路径:com.googlecode.d2j.reader.zip.ZipUtil
类名称:ZipUtil

ZipUtil介绍

暂无

代码示例

代码示例来源:origin: pxb1988/dex2jar

/**
 * read the dex file from file, if the file is a zip file, it will return the content of classes.dex in the zip
 * file.
 * 
 * @param file
 * @return
 * @throws IOException
 */
public static byte[] readDex(File file) throws IOException {
  return readDex(file.toPath());
}

代码示例来源:origin: pxb1988/dex2jar

public static byte[] readDex(InputStream in) throws IOException {
  return readDex(toByteArray(in));
}

代码示例来源:origin: pxb1988/dex2jar

/**
   * read the dex file from byte array, if the byte array is a zip stream, it will return the content of classes.dex
   * in the zip stream.
   * 
   * @param data
   * @return the content of classes.dex
   * @throws IOException
   */
  public static byte[] readDex(byte[] data) throws IOException {
    if (data.length < 3) {
      throw new IOException("File too small to be a dex/zip");
    }
    if ("dex".equals(new String(data, 0, 3, StandardCharsets.ISO_8859_1))) {// dex
      return data;
    } else if ("PK".equals(new String(data, 0, 2, StandardCharsets.ISO_8859_1))) {// ZIP
      try (ZipFile zipFile = new ZipFile(data)) {
        ZipEntry classes = zipFile.findFirstEntry("classes.dex");
        if (classes != null) {
          return toByteArray(zipFile.getInputStream(classes));
        } else {
          throw new IOException("Can not find classes.dex in zip file");
        }
      }
    }
    throw new IOException("the src file not a .dex or zip file");
  }
}

代码示例来源:origin: pxb1988/dex2jar

public static void checkZipFile(File zip) throws ZipException, Exception {
  ZipFile zipFile = new ZipFile(zip);
  for (Enumeration<? extends ZipEntry> e = zipFile.entries(); e.hasMoreElements();) {
    ZipEntry entry = e.nextElement();
    if (entry.getName().endsWith(".class")) {
      StringWriter sw = new StringWriter();
      // PrintWriter pw = new PrintWriter(sw);
      try (InputStream is = zipFile.getInputStream(entry)) {
        verify(new ClassReader(ZipUtil.toByteArray(is)));
      }
      Assert.assertTrue(sw.toString(), sw.toString().length() == 0);
    }
  }
}

代码示例来源:origin: pxb1988/dex2jar

public static byte[] readDex(Path file) throws IOException {
  return readDex(Files.readAllBytes(file));
}

代码示例来源:origin: SparkInLee/dexdiff

public static byte[] readDex(InputStream in) throws IOException {
  return readDex(toByteArray(in));
}

代码示例来源:origin: pxb1988/dex2jar

KeyFactory rSAKeyFactory = KeyFactory.getInstance("RSA");
PrivateKey privateKey = rSAKeyFactory.generatePrivate(new PKCS8EncodedKeySpec(ZipUtil
    .toByteArray(ApkSign.class.getResourceAsStream("ApkSign.private"))));

代码示例来源:origin: pxb1988/dex2jar

public static void doFile(Path srcDex, Path dest) throws IOException {
  doData(ZipUtil.readDex(srcDex), dest);
}

代码示例来源:origin: pxb1988/dex2jar

@Test
public void test0() throws IOException {
  byte[] data = ZipUtil.toByteArray(BadZipEntryFlagTest.class.getResourceAsStream("/bad.zip"));
  try (ZipFile zip = new ZipFile(data)) {
    for (com.googlecode.d2j.util.zip.ZipEntry e : zip.entries()) {
      System.out.println(e);
      if (!e.isDirectory()) {
        zip.getInputStream(e).read();
      }
    }
  }
}

代码示例来源:origin: pxb1988/dex2jar

public static Baksmali from(Path in) throws IOException {
  return from(ZipUtil.readDex(in));
}

代码示例来源:origin: SparkInLee/dexdiff

/**
   * read the dex file from byte array, if the byte array is a zip stream, it will return the content of classes.dex
   * in the zip stream.
   * 
   * @param data
   * @return the content of classes.dex
   * @throws IOException
   */
  public static byte[] readDex(byte[] data) throws IOException {
    if (data.length < 3) {
      throw new IOException("File too small to be a dex/zip");
    }
    if ("dex".equals(new String(data, 0, 3, StandardCharsets.ISO_8859_1))) {// dex
      return data;
    } else if ("PK".equals(new String(data, 0, 2, StandardCharsets.ISO_8859_1))) {// ZIP
      try (ZipFile zipFile = new ZipFile(data)) {
        ZipEntry classes = zipFile.findFirstEntry("classes.dex");
        if (classes != null) {
          return toByteArray(zipFile.getInputStream(classes));
        } else {
          throw new IOException("Can not find classes.dex in zip file");
        }
      }
    }
    throw new IOException("the src file not a .dex or zip file");
  }
}

代码示例来源:origin: pxb1988/dex2jar

public static Baksmali from(InputStream in) throws IOException {
  return from(ZipUtil.readDex(in));
}

代码示例来源:origin: pxb1988/dex2jar

public static Baksmali from(File in) throws IOException {
  return from(ZipUtil.readDex(in));
}

代码示例来源:origin: pxb1988/dex2jar

public static Dex2jar from(byte[] in) throws IOException {
  return from(new DexFileReader(ZipUtil.readDex(in)));
}

代码示例来源:origin: pxb1988/dex2jar

byte[] data = ZipUtil.readDex(new File(f).toPath());
DexFileReader r = new DexFileReader(data);
r.accept(fv);
byte[] data = ZipUtil.readDex(stub);
DexFileReader r = new DexFileReader(data);
r.accept(new DexFileVisitor(out) {

代码示例来源:origin: pxb1988/dex2jar

Map<String, DexClassNode> readDex(File path) throws IOException {
  DexFileReader dexFileReader = new DexFileReader(ZipUtil.readDex(path));
  DexFileNode dexFileNode = new DexFileNode();
  dexFileReader.accept(dexFileNode);
  Map<String, DexClassNode> map = new HashMap<>();
  for (DexClassNode c : dexFileNode.clzs) {
    map.put(c.className, c);
  }
  return map;
}

代码示例来源:origin: pxb1988/dex2jar

private DexFileNode readDex(Path f) {
  DexFileNode fileNode = new DexFileNode();
  DexFileReader reader = null;
  try {
    reader = new DexFileReader(ZipUtil.readDex(f));
  } catch (IOException e) {
    throw new RuntimeException("Fail to read dex:" + f);
  }
  reader.accept(fileNode);
  return fileNode;
}

代码示例来源:origin: SparkInLee/dexdiff

/**
 * read the dex file from file, if the file is a zip file, it will return the content of classes.dex in the zip
 * file.
 * 
 * @param file
 * @return
 * @throws IOException
 */
public static byte[] readDex(File file) throws IOException {
  return readDex(file.toPath());
}

代码示例来源:origin: SparkInLee/dexdiff

public static byte[] readDex(Path file) throws IOException {
  return readDex(Files.readAllBytes(file));
}

代码示例来源:origin: SparkInLee/dexdiff

public static void doFile(Path srcDex, Path dest) throws IOException {
  doData(ZipUtil.readDex(srcDex), dest);
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com