Guest User

Untitled

a guest
Apr 25th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import java.util.*;
  2. import java.net.*;
  3. import java.io.*;
  4.  
  5. public class ChatClient
  6. {
  7. public ChatClient()
  8. {
  9. scanner = new Scanner(System.in);
  10. }
  11.  
  12. public void run()
  13. {
  14. // Put console I/O code here, using scanner and System.out
  15.  
  16. try
  17. {
  18. Socket socket = new Socket("192.168.1.149", 27789);
  19.  
  20. PrintWriter writer = new PrintWriter(new BufferedWriter(
  21. new OutputStreamWriter(
  22. socket.getOutputStream())));
  23.  
  24. writer.println("We are all just pale Africans.");
  25. String message = "NULL";
  26. message = scanner.nextLine();
  27. writer.println(message);
  28. while(message != "quit")
  29. {
  30. message = scanner.nextLine();
  31. writer.println(message);
  32. }
  33.  
  34. writer.flush();
  35. writer.close();
  36. socket.close();
  37.  
  38. }
  39. catch (IOException ex)
  40. {
  41. System.out.println(ex.getMessage());
  42. }
  43.  
  44.  
  45. }
  46.  
  47. private Scanner scanner;
  48.  
  49. public static void main(String[] args)
  50. {
  51. ChatClient program = new ChatClient();
  52. program.run();
  53. }
  54. }
Add Comment
Please, Sign In to add comment