如何使用字节从BufferedInputStream创建字符串?
这个问题在这里已经有了答案:
缓冲区太大。 尝试这个:
InputStream content = new FileInputStream(file);
int numRead;
final int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
ByteArrayOutputStream outString = new ByteArrayOutputStream();
try{
while ((numRead = content.read(buffer)) != -1) {
outString.write(buffer, 0, numRead);
}
} finally {
content.close();
}
return new String(outString.toByteArray());
链接地址: http://www.djcxy.com/p/13733.html
上一篇: How to Create a string from a BufferedInputStream using bytes?