0

Possible Duplicate:
FileNotFoundException with URLConnection

This is my below program.

The URL is accessible, but why am I getting java.io.FileNotFoundException?

    public class TestGet {
    private static URL source; 
    public static void main(String[] args) {
        doGet();
    }
    public static void doGet() {
            try {
            source = new URL("http://localhost:8080/");
            URLConnection connection = source.openConnection();
            connection.connect();

            BufferedReader rdr =new BufferedReader(new InputStreamReader(connection.getInputStream()));
            StringBuffer b = new StringBuffer();
            String line = null;
            while (true) {
                line = rdr.readLine();
                if (line == null)
                      break;
                b.append(line);
          }

        } catch (Exception e) {
            System.err.println(e.toString());
        }
    }

}

java.io.FileNotFoundException: http://localhost:8080/

Community
  • 1
  • 1
Pavan Kumar
  • 211
  • 1
  • 5
  • 8

0 Answers0