开发者

How to read the whole json from url in stringbuffer?

I have read the JSON from URL whic开发者_如何学编程h contains thousands of records in the json format. I am not able to read all records in the JSON String format, that is, I am not able to store all records in a stringbuffer or stringbuilder. How should I do this?


Heres a little function I wrote to return a built string from JSON results. I hope this is what you mean.

public String getStringBuilderResults(InputStream inputstream) {
    try
    {
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputstream,"iso-8859-1"),8);
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
        inputstream.close();
        return sb.toString();
    } catch (Exception e) {
        return null;
    }

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜