You need to perform simple networking tasks via HTTP, such as downloading a file, and you want to avoid the performance penalty imposed by the more high-level, much larger and more complex Apache HttpClient implementation.
URL url = new URL("http://www.example.com/");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.connect();
...
conn.disconnect();
HttpURLConnection inherits from the more generic URLConnection,how does URL know what kind of connection to return? ......
阅读全文