我的代码发送 HttpConnection 然后尝试使用connection.getInputStream()
或connection.getErrorStream()
反序列化响应。
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); // getErrorStream()
String content = in.lines().collect(Collectors.joining());
如何在完成()后将连接传递给parse(HttpURLConnection connection)
函数并调用?connection.disconnect()
我在想
connection.disconnect();
return MyObject.fromString(connection.getInputStream(), connection.getErrorStream());
但不确定在阅读响应之前断开连接是否有意义。