For example,

try {
  URL u = new URL("http://www.poly.edu/fall97/grad.html#cs ");
  System.out.println("The protocol is " + u.getProtocol());
  System.out.println("The host is " + u.getHost());
  System.out.println("The port is " + u.getPort());
  System.out.println("The file is " + u.getFile());
  System.out.println("The anchor is " + u.getRef());
}
catch (MalformedURLException e) { }

Previous | Next | Top | Cafe con Leche

Copyright 1999, 2000 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified July 14, 2000