Thursday, 7 May 2015

JAVA PROGRAM TO DOWNLOAD HOMEPAGE OF THE SERVER

import java.net.*;
import java.io.*;

public class SourceViewer
{
public static void main(string[] args)
{
if(args.length>0)
{
try
{
URL u=new URL(args[0]);
InputStream in=u.openStream();
in=new BufferedInputStream(in);
int c;
while((c=r.read())!=-1)
{
System.out.println((char) c);
}
}
catch(MalformedURLExceptiom ex)
{
System.err.println(args[0]+”is not a parseable URL”);
}
catch(IOException ex)
{
System.err.println(ex);
}
}
}

}

No comments:

Post a Comment