-3

请我想要一种非常简单的方法来从我的 android 应用程序中读取我的 php 页面的内容!我不想要 jSon 什么的,我想要的只是让 php 页面的内容成为 java 中的字符串!提前谢谢你!

4

1 回答 1

4
    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)
于 2013-08-17T06:53:04.387 回答