Java HttpConnection refused, but curl equivalent works
I'm losing my mind on this one. My curl command works:

curl http://testuser:testpwd@qabox3:8501/xmlcontroller

But, when I try what looks like an equivalent http connection in Java it gives "connection refused". What am I missing? I've tried a dozen flavors of trying to make this connection today and am out of ideas.

            URL url = new URL( "http://qabox3:8051/xmlcontroller" );
            HttpURLConnection conn = (HttpURLConnection)url.openConnection();
            conn.setRequestMethod( "GET" );
            String encoding = new sun.misc.BASE64Encoder().encode( "testuser:testpwd".getBytes() );
            conn.setRequestProperty("Authorization", "Basic " + encoding );
            InputStream content = conn.getInputStream();  // <--- fails here every time.
            BufferedReader in = new BufferedReader( new InputStreamReader( content ) );
            String line;
            while ((line = in.readLine()) != null) {
                System.out.println( line );
            }
Java HttpConnection refused, but curl equivalent works
===

I'm losing my mind on this one. My curl command works:

curl http://testuser:testpwd@qabox3:8501/xmlcontroller

But, when I try what looks like an equivalent http connection in Java it gives "connection refused". What am I missing? I've tried a dozen flavors of trying to make this connection today and am out of ideas.

            URL url = new URL( "http://qabox3:8051/xmlcontroller" );
            HttpURLConnection conn = (HttpURLConnection)url.openConnection();
            conn.setRequestMethod( "GET" );
            String encoding = new sun.misc.BASE64Encoder().encode( "testuser:testpwd".getBytes() );
            conn.setRequestProperty("Authorization", "Basic " + encoding );
            InputStream content = conn.getInputStream();  // <--- fails here every time.
            BufferedReader in = new BufferedReader( new InputStreamReader( content ) );
            String line;
            while ((line = in.readLine()) != null) {
                System.out.println( line );
            }