1 回答

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超5個(gè)贊
嘗試將您的readCache()方法更改為
private void readCache(String filename) {
FileInputStream inputStream;
try {
inputStream = openFileInput(filename);
String body = inputStreamToString(inputStream);
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
private String inputStreamToString(InputStream inputStream) throws Exception {
ByteArrayOutputStream result = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
while ((length = inputStream.read(buffer)) != -1) {
result.write(buffer, 0, length);
}
return result.toString("UTF-8");
}
添加回答
舉報(bào)