Set URL of another Sever | Download Server homepage

To implement in java program
Set the URL of another server
Download the Home page of the Server CS1404 INTERNET PROGRAMMING LABORATORY
Algorithm
Start the program for Home page of the server
Declare the argument in the main function for the passing URL
Get the argument in the variable then assign the URL to that variable
Through the while loop get the data and display
Terminate the program for home page of the server
Source Code Java Program for Download the Home Page of the Server in
import java.net.*;
import java.io.*;
public class ViewSourceUrl {
public static void main (String[] args) {
if (args.length > 0) {
try {
URL rl = new URL(args[0]);
InputStream in = rl.openStream( );
in = new BufferedInputStream(in);
Reader r = new InputStreamReader(in);
int c;
while ((c = r.read( )) != -1) {
System.out.print((char) c);
}
}
catch (MalformedURLException er) {
System.err.println(args[0] +
" is not a parseable URL");
}
catch (IOException er) {
System.err.println(er);
}
}
}
}
Output CS1404 INTERNET PROGRAMMING LABORATORY

When you compile you must pass the augment in the command mode
Compile the program for Set URL of another Sever Download Server homepage
Javac ViewSourceUrl http://192.16.0.15
Run the program

Set URL of another Sever  Download Server homepage

Related post