gpt4 book ai didi

java - 未知格式(魔数(Magic Number) 5153)

转载 作者:行者123 更新时间:2023-12-01 15:28:34 24 4
gpt4 key购买 nike

当我尝试解压缩 .gz 文件并覆盖 db 文件时,我得到未知格式(魔数(Magic Number) 5153)。这是我的解压和覆盖代码。

           InputStream fIn = c.getAssets().open("MyContacts");
// Path to the just created empty db
String outFileName = DB_PATH + DB_NAME;

//Open the empty db as the output stream
FileOutputStream myOutput = new FileOutputStream(outFileName);
GZIPInputStream gz = new GZIPInputStream(fIn);

//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[10246];
int length;
while ((length = gz.read(buffer, 0,buffer.length)) != -1){
myOutput.write(buffer, 0, length);
}

//Close the streams

gz.close();
myOutput.flush();
myOutput.close();
fIn.close();

最佳答案

Assets 很可能在到达您的代码之前正在动态解压缩。 aapt 对于如何处理压缩资源文件有自己的独特想法。该行为部分取决于 Assets 文件名(据我所知,以未记录的方式)。最好将未压缩的文件放在 asset 目录中并让 aapt 为您压缩它们。它通常表现出色,让您不必担心此类事情。

请参阅 zapl 的评论所指向的博文。

关于java - 未知格式(魔数(Magic Number) 5153),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9863640/

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