断开连接的方法HttpURLConnection
似乎无法正常工作。如果我执行以下代码:
url = new URL("http:// ...");
connection = (HttpURLConnection) url.openConnection ();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
connection.connect();
// Some code
connection.disconnect();
connection.setDoInput(false); // -> IllegalStateException
IllegalStateException
当我调用该方法时,我得到一个setDoInput
。异常说:
已经连接