- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.googlecode.d2j.util.zip.ZipFile
类的一些代码示例,展示了ZipFile
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipFile
类的具体详情如下:
包路径:com.googlecode.d2j.util.zip.ZipFile
类名称:ZipFile
[英]This is code is get from Android 4.4.2 intent to read as more zip as possible Ignore GPBF_ENCRYPTED_FLAG Allow duplicate ZipEntry Allow Nul byte in ZipEntry name
[中]这是来自Android 4.4.2的代码,旨在尽可能多地读取zip忽略GPBF_加密_标志允许重复ZipEntry允许ZipEntry名称中的Nul字节
代码示例来源:origin: pxb1988/dex2jar
public static BaseDexFileReader open(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 new DexFileReader(data);
} else if ("PK".equals(new String(data, 0, 2, StandardCharsets.ISO_8859_1))) {// ZIP
TreeMap<String, DexFileReader> dexFileReaders = new TreeMap<>();
try (ZipFile zipFile = new ZipFile(data)) {
for (ZipEntry e : zipFile.entries()) {
String entryName = e.getName();
if (entryName.startsWith("classes") && entryName.endsWith(".dex")) {
if (!dexFileReaders.containsKey(entryName)) { // only the first one
dexFileReaders.put(entryName, new DexFileReader(toByteArray(zipFile.getInputStream(e))));
}
}
}
}
if (dexFileReaders.size() == 0) {
throw new IOException("Can not find classes.dex in zip file");
} else if (dexFileReaders.size() == 1) {
return dexFileReaders.firstEntry().getValue();
} else {
return new MultiDexFileReader(dexFileReaders.values());
}
}
throw new IOException("the src file not a .dex or zip file");
}
代码示例来源: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 ZipEntry findFirstEntry(String entryName) {
if (entryName == null) {
throw new NullPointerException("entryName == null");
}
ZipEntry ze = findFirstEntry0(entryName);
if (ze == null) {
ze = findFirstEntry0(entryName + "/");
}
return ze;
}
代码示例来源:origin: pxb1988/dex2jar
ZipEntry(ByteBuffer it0, boolean skipCommentsAndExtra) throws IOException {
ByteBuffer it = (ByteBuffer) it0.slice().order(ByteOrder.LITTLE_ENDIAN).limit(CENHDR);
ZipFile.skip(it0, CENHDR);
int sig = it.getInt();
if (sig != CENSIG) {
ZipFile.throwZipException("Central Directory Entry", sig);
ZipFile.skip(it0, extraLength);
} else {
extra = new byte[extraLength];
ZipFile.skip(it0, commentByteCount);
} else {
byte[] commentBytes = new byte[commentByteCount];
代码示例来源:origin: pxb1988/dex2jar
public ZipFile(ByteBuffer in) throws IOException {
raf = in.asReadOnlyBuffer().order(ByteOrder.LITTLE_ENDIAN);
readCentralDir();
}
代码示例来源:origin: pxb1988/dex2jar
/**
* Returns an input stream on the data of the specified {@code android.ZipEntry}.
*
* @param entry
* the android.ZipEntry.
* @return an input stream of the data contained in the {@code android.ZipEntry}.
* @throws java.io.IOException
* if an {@code IOException} occurs.
* @throws IllegalStateException
* if this zip file has been closed.
*/
public InputStream getInputStream(ZipEntry entry) throws IOException {
long entryDataStart = getEntryDataStart(entry);
ByteBuffer is = (ByteBuffer) raf.duplicate().position((int) entryDataStart);
if (entry.compressionMethod == ZipEntry.STORED) {
final ByteBuffer buf = (ByteBuffer) is.slice().order(ByteOrder.LITTLE_ENDIAN).limit((int) entry.size);
return new ByteBufferBackedInputStream(buf);
} else {
final ByteBuffer buf = (ByteBuffer) is.slice().order(ByteOrder.LITTLE_ENDIAN)
.limit((int) entry.compressedSize);
int bufSize = Math.max(1024, (int) Math.min(entry.getSize(), 65535L));
return new ZipInflaterInputStream(new ByteBufferBackedInputStream(buf), new Inflater(true), bufSize, entry);
}
}
代码示例来源:origin: pxb1988/dex2jar
int numEntries = raf.getShort() & 0xffff;
int totalNumEntries = raf.getShort() & 0xffff;
skip(raf, 4); // Ignore centralDirSize.
long centralDirOffset = ((long) raf.getInt()) & 0xffffffffL;
int commentLength = raf.getShort() & 0xffff;
} else {
if (skipCommentsAndExtra) {
skip(raf, commentLength);
} else {
byte[] commentBytes = new byte[commentLength];
代码示例来源:origin: SparkInLee/dexdiff
ZipEntry(ByteBuffer it0, boolean skipCommentsAndExtra) throws IOException {
ByteBuffer it = (ByteBuffer) it0.slice().order(ByteOrder.LITTLE_ENDIAN).limit(CENHDR);
ZipFile.skip(it0, CENHDR);
int sig = it.getInt();
if (sig != CENSIG) {
ZipFile.throwZipException("Central Directory Entry", sig);
ZipFile.skip(it0, extraLength);
} else {
extra = new byte[extraLength];
ZipFile.skip(it0, commentByteCount);
} else {
byte[] commentBytes = new byte[commentByteCount];
代码示例来源:origin: pxb1988/dex2jar
public ZipFile(File fd) throws IOException {
RandomAccessFile randomAccessFile = new RandomAccessFile(fd, "r");
file = randomAccessFile;
raf = randomAccessFile.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, fd.length());
readCentralDir();
}
代码示例来源:origin: SparkInLee/dexdiff
/**
* Returns an input stream on the data of the specified {@code android.ZipEntry}.
*
* @param entry
* the android.ZipEntry.
* @return an input stream of the data contained in the {@code android.ZipEntry}.
* @throws java.io.IOException
* if an {@code IOException} occurs.
* @throws IllegalStateException
* if this zip file has been closed.
*/
public InputStream getInputStream(ZipEntry entry) throws IOException {
long entryDataStart = getEntryDataStart(entry);
ByteBuffer is = (ByteBuffer) raf.duplicate().position((int) entryDataStart);
if (entry.compressionMethod == ZipEntry.STORED) {
final ByteBuffer buf = (ByteBuffer) is.slice().order(ByteOrder.LITTLE_ENDIAN).limit((int) entry.size);
return new ByteBufferBackedInputStream(buf);
} else {
final ByteBuffer buf = (ByteBuffer) is.slice().order(ByteOrder.LITTLE_ENDIAN)
.limit((int) entry.compressedSize);
int bufSize = Math.max(1024, (int) Math.min(entry.getSize(), 65535L));
return new ZipInflaterInputStream(new ByteBufferBackedInputStream(buf), new Inflater(true), bufSize, entry);
}
}
代码示例来源:origin: SparkInLee/dexdiff
int numEntries = raf.getShort() & 0xffff;
int totalNumEntries = raf.getShort() & 0xffff;
skip(raf, 4); // Ignore centralDirSize.
long centralDirOffset = ((long) raf.getInt()) & 0xffffffffL;
int commentLength = raf.getShort() & 0xffff;
skip(raf, commentLength);
} else {
byte[] commentBytes = new byte[commentLength];
代码示例来源:origin: pxb1988/dex2jar
try (ZipOutputStream zos = new AutoSTOREDZipOutputStream(Files.newOutputStream(output))) {
byte[] data = Files.readAllBytes(new File(remainingArgs[0]).toPath());
try(com.googlecode.d2j.util.zip.ZipFile zipFile = new com.googlecode.d2j.util.zip.ZipFile(data)) {
for (com.googlecode.d2j.util.zip.ZipEntry e : zipFile.entries()) {
ZipEntry nEntry = new ZipEntry(e.getName());
try (InputStream is = zipFile.getInputStream(e)) {
while (true) {
int c = is.read(buffer);
代码示例来源: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: SparkInLee/dexdiff
public ZipFile(ByteBuffer in) throws IOException {
raf = in.asReadOnlyBuffer().order(ByteOrder.LITTLE_ENDIAN);
readCentralDir();
}
代码示例来源:origin: SparkInLee/dexdiff
public ZipEntry findFirstEntry(String entryName) {
if (entryName == null) {
throw new NullPointerException("entryName == null");
}
ZipEntry ze = findFirstEntry0(entryName);
if (ze == null) {
ze = findFirstEntry0(entryName + "/");
}
return ze;
}
代码示例来源: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: SparkInLee/dexdiff
public ZipFile(File fd) throws IOException {
RandomAccessFile randomAccessFile = new RandomAccessFile(fd, "r");
file = randomAccessFile;
raf = randomAccessFile.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, fd.length());
readCentralDir();
}
代码示例来源:origin: SparkInLee/dexdiff
public static BaseDexFileReader open(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 new DexFileReader(data);
} else if ("PK".equals(new String(data, 0, 2, StandardCharsets.ISO_8859_1))) {// ZIP
TreeMap<String, DexFileReader> dexFileReaders = new TreeMap<>();
try (ZipFile zipFile = new ZipFile(data)) {
for (ZipEntry e : zipFile.entries()) {
String entryName = e.getName();
if (entryName.startsWith("classes") && entryName.endsWith(".dex")) {
if (!dexFileReaders.containsKey(entryName)) { // only the first one
dexFileReaders.put(entryName, new DexFileReader(toByteArray(zipFile.getInputStream(e))));
}
}
}
}
if (dexFileReaders.size() == 0) {
throw new IOException("Can not find classes.dex in zip file");
} else if (dexFileReaders.size() == 1) {
return dexFileReaders.firstEntry().getValue();
} else {
return new MultiDexFileReader(dexFileReaders.values());
}
}
throw new IOException("the src file not a .dex or zip file");
}
在C语言中,当有变量(假设都是int)i小于j时,我们可以用等式 i^=j^=i^=j 交换两个变量的值。例如,令int i = 3,j = 5;在计算 i^=j^=i^=j 之后,我有 i = 5,
我为以下问题编写了以下代码: 给定一个由 N 个正整数组成的序列 A,编写一个程序来查找满足 i > A[j]A[i](A[i] 的 A[j] 次方 > A[j] 的 A[i] 次方)。 我的代码通过
这个表达式是从左到右解析的吗?我试图解释解析的结果,但最后的结果是错误的。 int j=10, k=10; j+=j-=j*=j; //j=j+(j-=j*=j)=j+(j-j*j) k+=k*=
给定一个整数数组 A ,我试图找出在给定位置 j ,A[j] 从每个 i=0 到 i=j 在 A 中出现了多少次。我设计了一个如下所示的解决方案 map CF[400005]; for(int i=0
你能帮我算法吗: 给定 2 个相同大小的数组 a[]和 b[]具有大于或等于 1 的整数。 查找不相等的索引 i和 j ( i != j ) 使得值 -max(a[i]*b[i] + a[i] * b
每次用J的M.副词,性能显着下降。因为我怀疑艾弗森和许比我聪明得多,我一定是做错了什么。 考虑 Collatz conjecture .这里似乎有各种各样的内存机会,但不管我放在哪里M. ,性能太差了
假设一个包含各种类型的盒装矩阵: matrix =: ('abc';'defgh';23),:('foo';'bar';45) matrix +---+-----+--+|abc|defgh|23|+
是否有可能对于两个正整数 i 和 j,(-i)/j 不等于 -(i/j)?我不知道这是否可能......我认为这将是关于位的东西,或者 char 类型的溢出或其他东西,但我找不到它。有什么想法吗? 最
假设两个不同大小的数组: N0 =: i. 50 N1 =: i. 500 应该有一种方法可以获得唯一的对,只需将两者结合起来即可。我发现的“最简单”是: ]$R =: |:,"2 |: (,.N0)
我是 J 的新用户,我只是想知道 J 包中是否实现了三次样条插值方法? 最佳答案 我自己不熟悉,但是我确实安装了所有的包,所以 $ rg -l -i spline /usr/share/j/9.02
在 Q/kdb 中,您可以使用 ': 轻松修改动词,它代表每个优先级。它会将动词应用于一个元素及其之前的邻居。例如 =': 检查值对是否相等。在 J 中,您可以轻松折叠 /\ 但它是累积的,是否有成对
嗨,我有一个 4x4 双矩阵 A 1+2i 2-1i -3-2i -1+4i 3-1i -3+2i 1-3i -1-3i 4+3i 3+5i 1-2i -1-4i
刚刚发现 J 语言,我输入: 1+^o.*0j1 I expected the answer to be 0 ,但我得到了 0j1.22465e_16。虽然这非常接近于 0,但我想知道为什么 J 应该
这个问题在这里已经有了答案: With arrays, why is it the case that a[5] == 5[a]? (20 个答案) 关闭 3 年前。 我正在阅读“C++ 编程语言”
当第一行是 1, 1/2 , 1/3 ....这是支持该问题的图像。 是否存在比朴素的 O(n^2) 方法更有效的方法? 我在研究伯努利数时遇到了这个问题,然后在研究“Akiyama-Tanigawa
我写了一段Java代码,它在无限循环中运行。 下面是代码: public class TestProgram { public static void main(String[] args){
for (int i = n; i > 0; i /= 2) { for (int j = 0; j 0; i /= 2) 的第一个循环结果 O(log N) . 第二个循环for (int
如问题中所述,需要找到数组中 (i,j) 对的总数,使得 (1) **ia[j]** 其中 i 和 j 是数组的索引。没有空间限制。 我的问题是 1) Is there any approach w
for l in range(1,len(S)-1): for i in range(1,len(S)-l): j=i+l for X in N:
第二个for循环的复杂度是多少?会是n-i吗?根据我的理解,第一个 for 循环将执行 n 次,但第二个 for 循环中的索引设置为 i。 //where n is the number elemen
我是一名优秀的程序员,十分优秀!