安卓 java。util。拉链ZipInputStream在解压过程中部分为空
已从生产服务器提供的web响应中检索到的压缩xml字符串。 字符串与中的方法相同。net给出了有效的结果。(数据是汽车品牌的列表。) 然而,在Android中,ZipInputStream读取产生一个大小合适的缓冲区(4895),但从2661位置开始,它有空数据。最后一辆正确解压的汽车是“MG”
该方法不会出错
有人能看出哪里出了问题吗? 谢谢
private byte[] decompressZip(String zipText) throws IOException{
try {
byte[] zipBytes = MakeBytes(zipText);
byte[] zipData;
ByteArrayInputStream b = new ByteArrayInputStream(zipBytes);
BufferedInputStream buf = new BufferedInputStream(b);
//ZipInputStream zin = new ZipInputStream(b); doesn't matter both constuctors have the fault.
ZipInputStream zin = new ZipInputStream(buf);
ZipEntry entry;
if((entry=zin.getNextEntry())!=null)
{
int entrySize=(int)entry.getSize();
zipData = new byte[entrySize];
zin.read(zipData, 0, entrySize);
return zipData;
}
} catch (Exception e) {
// TODO Auto-generated catch block
String sError = e.getMessage();
}
return null;
}
共 (0) 个答案