sender

                                                      


import java.io.*;
import java.net.*;
import java.util.*;
public class sender
{
public static void main(String args[])throws Exception
{
try{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("ENter the file name");
String fname=br.readLine();
File f=new File(fname);
FileReader fr=new FileReader(f);
Socket s=new Socket("127.0.0.1",8081);
PrintWriter put=new PrintWriter(s.getOutputStream(),true);
put.println(f);
int c=0,k=0,s1=0;
while((c=fr.read())!=-1)
{
k++;
if(k<9)
{
put.println(c);
}
if(k>24)
{
put.println(c);
}
if(k>8 && k<25)
{
 if(c==1)
 {
s1=s1+1;
put.println(c);
 }
 else
 {
put.println(c);
s1=0;
 }
 if(s1==5)
 {
c='0';
put.println(c);
s1=0;
 }
 else{}
}
else{}
}
fr.close();
s.close();
}catch(Exception e){System.out.println(""+e);}
}
}

No comments:

Post a Comment