import java.net.*;
import java.io.*;
public class viewsource {
public static void main (String args[]) {
String thisLine;
URL u;
if (args.length > 0) {
//Open the URL for reading
try {
u = new URL(args[0]);
// now turn the URL into a DataInputStream
try {
DataInputStream theHTML = new DataInputStream(u.openStream());
try {
while ((thisLine = theHTML.readLine()) != null) {
System.out.println(thisLine);
} // while loop ends here
} // end try
catch (Exception e) {
System.err.println(e);
}
} // end try
catch (Exception e) {
System.err.println(e);
}
} // end try
catch (MalformedURLException e) {
System.err.println(args[0] + " is not a parseable URL");
System.err.println(e);
}
} // end if
} // end main
} // end viewsource
|