try { URL u = new URL("http://www.oreilly.com/"); URLConnection uc = u.openConnection(); System.out.println(uc.getURL()); } catch (IOException ex) { System.err.println(ex); }