Tuesday, 28 February 2012

HTML

import java.io.*;
import java.net.*;
class client
{
public static void main(String args[]) throws IOException
{
try
{
Socket s=new Socket("localhost",4000);
DataInputStream in =new DataInputStream(System.in);
DataInputStream din =new DataInputStream(s.getInputStream());
PrintStream p = new PrintStream(s.getOutputStream());
String str,str1;
System.out.println("Enter the HTML file name");
str=in.readLine();
p.println(str);
System.out.println("Program code for the HTML file specified are\n______________________________");
while(str!=null)
{
str1=din.readLine( );
System.out.println(str1);
}
}
catch(Exception e)
{
System.out.println();
}
}
}



import java.io.*;
import java.net.*;
class server
{
public static void main(String args[]) throws IOException
{
try
{
ServerSocket ss = new ServerSocket(4000);
System.out.println("Waiting for the client connection---");
Socket s=ss.accept();
System.out.println("Client connected--");
DataInputStream in = new DataInputStream(s.getInputStream());
PrintStream p = new PrintStream(s.getOutputStream());
String str;
str=in.readLine();
FileReader fr = new FileReader(str);
BufferedReader br = new BufferedReader(fr);
Runtime.getRuntime( ).exec("c:\\windows\\explorer.exe"+" "+str);
}
catch(Exception e)
{
System.out.println(e);
}
}
}

No comments:

Post a Comment