Java 同一连接中的多个JSON请求
我需要执行多个JSON请求,但无法关闭当前连接 示例代码:Java 同一连接中的多个JSON请求,java,json,session,urlconnection,Java,Json,Session,Urlconnection,我需要执行多个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(
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;
}
或
有什么选择吗?解决了
要在同一个会话中执行多个json请求,我只需要保存第一个会话中的cookie,然后将其与其他会话一起使用
这个链接帮助了我格式化JSON方法的作用是什么?你在读inputStream的所有可用输入吗?我已经解决了这个问题,
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;
}