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