【发布时间】:2013-10-24 20:40:20
【问题描述】:
我有一个需要在连接中设置请求属性的 Android 应用。这是我的代码:
URL url = new URL(sUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("cookie", cookievalue);
connection.connect();
当我调用 setRequestProperty 方法时,它会启动异常:
java.lang.IllegalStateException: Cannot set request property after connection is made
有没有办法在不使用 url.openConnection() 的情况下创建到文件的连接?
【问题讨论】:
标签: java android httpurlconnection illegalstateexception