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());
精彩评论