已从生产服务器给出的 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;
}