Sunday 12 August 2007

Simple URL Object example

import java.net.*;

class testURL {
public static void main(String args[]) throws MalformedURLException {
URL testURL1 = new URL("http://help.blogger.com/bin/static.py?page=start.cs");
// create cs URL object
System.out.println("Protocal : " + testURL1.getProtocol());
System.out.println("Port: " + testURL1.getPort());
System.out.println("Host: " + testURL1.getHost());
System.out.println("File(include full location): " + testURL1.getFile());
System.out.println("full URL: " + testURL1.toExternalForm());
}
}

No comments: