1
我目前的代码需要从网上读取外来字符,目前我的解决方案工作,但它非常慢,因为它使用InputStreamReader读char字符。无论如何要加快速度并完成工作?java:加速读取外来字符
// Pull content stream from response
HttpEntity entity = response.getEntity();
InputStream inputStream = entity.getContent();
StringBuilder contents = new StringBuilder();
int ch;
InputStreamReader isr = new InputStreamReader(inputStream, "gb2312");
// FileInputStream file = new InputStream(is);
while((ch = isr.read()) != -1)
contents.append((char)ch);
String encode = isr.getEncoding();
return contents.toString();