0

我需要点击 URL 并获得响应,但是通过这种方法我只能获得一条消息,而我想传递多个值作为响应。

这是方法:

public String getOutputFromUrl(String url) 
    {
        Log.d("in getOutputFromUrl", "getOutputFromUrl");
        String[] output = null;
        try {
            httpClient = new DefaultHttpClient();
            httpGet = new HttpGet(url);
            httpResponse = httpClient.execute(httpGet);
            httpEntity = httpResponse.getEntity();
            output = EntityUtils.toString(httpEntity);
        } catch (UnsupportedEncodingException e) {
            Log.d("in UnsupportedEncodingException", e.toString());
            e.printStackTrace();
        } catch (ClientProtocolException e) {
            Log.d("in geClientProtocolExceptiontOutputFromUrl",  e.toString());
            e.printStackTrace();
        } catch (IOException e) {
            Log.d("in getOutputFromUrl", e.toString());
            e.printStackTrace();
        }
        Log.d("in getOutputFromUrl:output===>>", output);

        return output;
     }

我希望方法的返回类型是 String[] 或任何类的对象,但是

 output = EntityUtils.toString(httpEntity)

这一行只接受一个字符串;没有其他对象或字符串数​​组,所以我不能在这个输出变量中保留多个值作为来自 URL 链接的响应传递

4

0 回答 0