sld22525482
「已注销」
2016-06-30 09:01

JAVA中一个函数怎么调用另一个函数运行后得到的结果?传参。求指点。。

代码:
public void urlCon() {
try {
URL url = new URL(PATH + input);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setConnectTimeout(5000);
connection.setReadTimeout(8000);
connection.setRequestMethod("GET");
connection.setUseCaches(false);
connection.setDoOutput(true);
connection.setDoInput(true);
OutputStream outputStream = connection.getOutputStream();
outputStream.flush();
connection.getResponseCode();

        InputStream in = connection.getInputStream();
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
       final StringBuilder response = new StringBuilder();
        String line;
        while ((line = reader.readLine()) != null) {
            response.append(line);
        }
        Log.i("返回的数据是 ", response.toString());

    } catch (MalformedURLException e1) {
        e1.printStackTrace();
    } catch (ProtocolException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

}

这个函数运行后得到的结果是 response.toString()是一个字符串,现在又定义了一个函数public void eight() {}在这个函数里面我想定义一个字符串就是response.toString(),请问这个参数要怎么传进来?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

5条回答