我需要执行多个JSON请求,但我无法关闭当前连接
示例代码:
private String[] test(URL url, final URL url2) throws IOException {
String[] test = new String[2];
URLConnection openConnection = url.openConnection();
test[0] = this.formatJSON(openConnection.getInputStream());
url = url2;
test[1] = this.formatJSON(openConnection.getInputStream());
return test;
}
或
private String[] test(URL url, final URL url2) throws IOException {
String[] test = new String[2];
URLConnection openConnection = url.openConnection();
test[0] = this.formatJSON(openConnection.getInputStream());
url.setNewURL(url2);
test[1] = this.formatJSON(openConnection.getInputStream());
return test;
}
任何选项?
答案 0 :(得分:0)
解决了!
要在同一会话中执行多个json请求,我只需要保存第一个的cookie,然后将其与其他人一起使用。