ftpc.java 846 B

1234567891011121314151617181920212223242526272829303132333435
  1. import java.io.*;
  2. import java.net.*;
  3. public class ftpc
  4. {
  5. public static void main(String arg[]) throws IOException
  6. {
  7. try
  8. {
  9. DatagramSocket sock=new DatagramSocket();
  10. InetAddress ip=InetAddress.getByName("localhost");
  11. FileReader fr=new FileReader("input.txt");
  12. BufferedReader x=new BufferedReader(fr);
  13. String str1;
  14. while((str1=x.readLine())!=null)
  15. {
  16. byte[] send;
  17. byte[] recieve=new byte[1024];
  18. send=str1.getBytes();
  19. DatagramPacket sendpack=new DatagramPacket(send,send.length,ip,5060);
  20. sock.send(sendpack);
  21. // DatagramPacket recepack=new DatagramPacket(recieve,recieve.length);
  22. // sock.receive(recepack);
  23. // String str=new String(recepack.getData(),0,recepack.getLength());
  24. // System.out.println("read the content"+str);
  25. }
  26. x.close();
  27. }
  28. catch(Exception e)
  29. {
  30. System.out.println(""+e);
  31. }
  32. }
  33. }