import java.net.*;
public class URLSplitter {
public static void main(String[] args) {
for (int i = 0; i < args.length; i++) {
try {
URL u = new URL(args[i]);
System.out.println("Protocol: " + u.getProtocol());
System.out.println("Host: " + u.getHost());
System.out.println("Port: " + u.getPort());
System.out.println("File: " + u.getFile());
System.out.println("Ref: " + u.getRef());
}
catch (MalformedURLException e) {
System.err.println(args[i] + " is not a valid URL");
}
}
}
}
This does not affect the final compiled code at all. However compilation will take a little longer. In general the time you save in not having to recover from error messages about missing classes more than makes up for the time you lose in compilation.