zlib 压缩文件是一个文本文件,大小为 31KB。解压后只解压一部分。这是我的代码,
public static String decompress(String filePath){
String jsonString = null;
try {
InputStream is = new FileInputStream(filePath);
InflaterInputStream inFlaterStream = new InflaterInputStream(is);
jsonString = Common.convertStreamToString(inFlaterStream);
} catch (Exception e) {
e.printStackTrace();
return null;
}
if (jsonString != null && jsonString.length() == 0){
return null;
}
return jsonString;
}
public static String convertStreamToString(InputStream is) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
return sb.toString();
}
sb.append(line) 行只执行了一次,我猜上面的代码中可能存在一些 Java IO 操作问题。但是我自己搞不定,有谁能帮忙吗?