在代码中:
HttpURLConnection connection = (HttpURLConnection)createMerchURL.openConnection();
connection.setRequestMethod("PUT");
connection.addRequestProperty("Name", "Value1");
connection.connect();
..
connection.disconnect();
实际上什么时候打开连接?在
..createMerchURL.openConnection();
? 或在connection.connect();
?如何在
connection
对象中设置 URL 并将其用于connection.connect()
?(因为我不太习惯.openConnection()
)
最后,这两者有什么区别吗?
谢谢..