简体   繁体   中英

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. 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." ( 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. But what is confusing is that you get 10,000 characters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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