Android Read contents of a URL (content missing after in result)

Posted by josnidhin on Stack Overflow See other posts from Stack Overflow or by josnidhin
Published on 2010-01-19T15:23:46Z Indexed on 2010/03/18 8:31 UTC
Read the original article Hit count: 189

Filed under:

I have the following code that reads the content of a url

public static String DownloadText(String url){
    StringBuffer result = new StringBuffer();
    try{
        URL jsonUrl = new URL(url);

        InputStreamReader isr  = new InputStreamReader(jsonUrl.openStream());

        BufferedReader in = new BufferedReader(isr);

        String inputLine;

        while ((inputLine = in.readLine()) != null){
            result.append(inputLine);
        }
    }catch(Exception ex){
        result = new StringBuffer("TIMEOUT");
        Log.e(Util.AppName, ex.toString());
    }
        in.close();
        isr.close();
    return result.toString();
}

The problem is I am missing content after 4065 characters in the result returned. Can someone help me solve this problem.

Note: The url I am trying to read contains a json response so everything is in one line I think thats why I am having some content missing.

© Stack Overflow or respective owner

Related posts about android