请我想要一个很简单的方法来从我的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)