简体   繁体   English

使用InputStreamReader仅获取一部分文本

[英]Getting only a part of text with InputStreamReader

I am reading from InputStreamReader but I only get the first 10,000 characters of the text that is supposed to come. 我正在从InputStreamReader中读取内容,但是我只能得到应该出现的文本的前10,000个字符。 Any idea what the problem may be? 知道可能是什么问题吗? If there is no solution with this class, what are my alternatives? 如果此类没有解决方案,那我有什么选择?

I found this about InputStreamReader: "The buffer size is 8K." 我发现有关InputStreamReader的信息:“缓冲区大小为8K。” ( http://developer.android.com/reference/java/io/InputStreamReader.html ). http://developer.android.com/reference/java/io/InputStreamReader.html )。 Could this be the answer? 这可能是答案吗?

Any pointers really appreciated 任何指针真的很感激

    StringBuilder sb = new StringBuilder();  

    BufferedReader br = new BufferedReader(new InputStreamReader(  
      httpcon.getInputStream(),"utf-8"));  
    String line = null;  
    while ((line = br.readLine()) != null) {  
        sb.append(line);               
    }                  
    br.close();  
    result = sb.toString();

8K buffer would mean 8000 bytes and since one character is one byte that would seem to make some sense as to your problem. 8K缓冲区将意味着8000个字节,并且由于一个字符是一个字节,因此对于您的问题似乎有些道理。 But what is confusing is that you get 10,000 characters. 但是令人困惑的是,您得到10,000个字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM