connecting to a URL in Java through a proxy
<p>I'm trying to write a small java program that connects to a twitter search URL (which returns a JSON list of tweets) using the URL connection libary.  </p>

<p>My code which is taken from the java tutorials looks like :</p>

<pre><code>        public static void main(String[] args) throws Exception {
        URL oracle = new URL("http://search.twitter.com/search.json?q=hi");
        URLConnection yc = oracle.openConnection();
        BufferedReader in = new BufferedReader(
                                new InputStreamReader(
                                yc.getInputStream()));
        String inputLine;

        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
    }
</code></pre>

<p>but for some reason I keep getting the following Exception:</p>

<pre><code>in thread "main" java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
</code></pre>

<p>I don't know if this is something due to the way I've written the code, and eclipse setting or something to do with my network. I do have a proxy server configured for internet access. As far as I know this is properly configured because I am getting updates and can install new software through eclipse. Do I need to put the proxy information in the URL method somehow or is something else the problem. </p>
