I have a code like this:
HttpURLConnection connection = (HttpURLConnection) loginUrl.openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36");
connection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
connection.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8");
connection.setRequestProperty("Connection", "keep-alive");
connection.setRequestProperty("Referer", "http://www.icourse163.org/member/logout.htm");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setDoOutput(true);
OutputStream out = connection.getOutputStream();
I the connection is a instance of HttpURLConnection, But when I debug the code. When the code runs to OutputStream out = connection.getOutputStream();.I saw that the getOutputStream() is the sun.net.www.protocol.http.HttpURLConnection's method. why?
Because java.net.HttpURLConnection is an abstract class, and sun.net.www.protocol.http.HttpURLConnection is its implementation in the Oracle JRE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With