Download webpage using java server socket.

Download webpage using java server socket. 

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

class readWebPage
{
public static void main(String arg[])
{
try{

Socket s = new Socket("10.0.0.1",8090);
String line="";
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));

PrintWriter out = new PrintWriter(s.getOutputStream());

out.print("GET /httpclient.htmlnn");
out.flush();
System.out.println("Reading File");
while((line = in.readLine())!=null)
{

System.out.println(line);
}

}
catch(Exception e)
{
System.out.println(e.toString());
}
}}

Share Post