views:

139

answers:

3

Where can I find the actual code (be it java or native) that's executed by:

new URL("http://google.com").openConnection().getOutputStream()

Bonus: how I can debug it from IntelliJ IDEA ?

+3  A: 

It's part of the JDK (since, er, dunno...): look for a "src.zip" archive within the root folder of your JDK installation.

Dirk
A: 

A quick Google reveals this direct link to HttpUrlConnection and related classes.

You should just be able to point Intellij at the source jar, and it'll tie it in automatically. I don't have Intellij at hand at the moment, but it's pretty trivial.

Brian Agnew
+1  A: 

The URLConnection has a plugin architecture. You can configure different handlers for each protocol. The Sun's default handler for HTTP is

  sun.net.www.protocol.http.HttpURLConnection

This one in turn uses this class to make HTTP calls,

  sun.net.www.http.HttpClient
ZZ Coder