开发者

Getting data from web service from android

    HttpClient client = new DefaultHttpClient();
    HttpGet request = new HttpGet();开发者_开发知识库
    request.setURI(new URI(address));
    HttpResponse response = client.execute(request);
    BufferedReader in = new BufferedReader(new 
InputStreamReader(response.getEntity().getContent()));

When I retrieve information like that, bufferedreader in contains only one long line with the whole text. It doesn't divide break data into lines. As a result, only first 3 kwords are fit into the line and the rest is losed. How can I avoid this problem?


Simply

URL url = new URI(address).toURL();
InputStream is = url.openStream();


Have you try this?

String data = EntityUtils.toString(response.getEntity());
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜