[英]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. 当我检索到这样的信息时,bufferedreader中的整个文本仅包含一长行。 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.
结果,只有前3个关键字适合该行,其余的则丢失。 How can I avoid this problem?
如何避免这个问题?
Simply 只是
URL url = new URI(address).toURL();
InputStream is = url.openStream();
你有尝试过吗?
String data = EntityUtils.toString(response.getEntity());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.