Oh sorry, the code should be this: URL url = new URL("http://www.yahoo.com/"); and this time, the result is correct. It is my bad. Sorry.