阅读使用日食的android PHP页面内容 [英] Read php page content from android using eclipse
本文介绍了阅读使用日食的android PHP页面内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请我想要一个很简单的方法来从我的Android应用程序读取我的PHP网页的内容!我不希望JSON或什么的,我要的是有PHP页面Java中的字符串的内容!感谢youu提前!
解决方案
HttpClient的客户端=新DefaultHttpClient();
HTTPGET请求=新HTTPGET(URL);
HTT presponse响应= client.execute(要求);
字符串的HTML =;
。InputStream的时间= response.getEntity()的getContent();
的BufferedReader读卡器=新的BufferedReader(新的InputStreamReader(在));
StringBuilder的海峡=新的StringBuilder();
串线= NULL;
而((行= reader.readLine())!= NULL)
{
str.append(线);
}
附寄();
的HTML = str.toString();
Log.i('HtmlContent',+ HTML)
Please I want a very simple way to read the content of my php page from my android app! I don't want jSon or something, all I want is to have the content of the php page a String in java! Thank youu in advance!
解决方案
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
String html = "";
InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder str = new StringBuilder();
String line = null;
while((line = reader.readLine()) != null)
{
str.append(line);
}
in.close();
html = str.toString();
Log.i('HtmlContent',+html)
这篇关于阅读使用日食的android PHP页面内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文