You can also construct the URL by passing its pieces to the constructor, like this:
try { URL u = new URL("http", "www.poly.edu", "/schedule/fall97/bgrad.html#cs"); // work with the URL } catch (MalformedURLException e) {}