Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. while ((line = reader.readLine()) != null)
  2. {
  3. output += line + "n";
  4. }
  5.  
  6. if (clinetChoice.equals("3"))
  7. {
  8. String command = "free";
  9.  
  10. Process process = Runtime.getRuntime().exec(command);
  11.  
  12. BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
  13.  
  14. System.out.println("You Chose Option Three");
  15.  
  16. String line;
  17.  
  18. while ((line = reader.readLine()) != null)
  19. {
  20. output += line;
  21. System.out.println(line);
  22. line = reader.readLine();
  23. }
  24.  
  25. }
  26.  
  27. while ((fromServer = input.readLine())+"n" != null)
  28. {
  29. System.out.println("Server: " + fromServer);
  30. if (fromServer.equals("Bye"))
  31. break;
  32.  
  33. System.out.print("Enter your choice: ");
  34. fromClient = stdIn.readLine().trim();
  35.  
  36. if(fromClient.equals("1"))
  37. {
  38. System.out.println("Client: " + fromClient);
  39. output.println(fromClient);
  40.  
  41. }
  42.  
  43. One
  44. Two
  45. Three
  46. Four
  47.  
  48. One
  49. Enter your choice: (It prompts me for new command)
  50. Two
  51. Enter your choice:
  52. Three
  53. Enter your choice:
  54. Four
  55.  
  56. One
  57. Two
  58. Three
  59. Four
  60. Enter your choice:
  61.  
  62. String fromServer = "";
  63. String line;
  64. while ((line = input.readLine()) != null) {
  65. fromServer += line + "n"; // collect multiline strings into fromServer
  66. }
  67.  
  68. System.out.println("Server: " + fromServer);
  69. if (fromServer.equals("Bye"))
  70. break;
  71.  
  72. System.out.print("Enter your choice: ");
  73. fromClient = stdIn.readLine().trim();
  74.  
  75. if(fromClient.equals("1"))
  76. {
  77. System.out.println("Client: " + fromClient);
  78. output.println(fromClient);
  79. }
  80.  
  81. System.out.print("Enter your choice: ");
  82. fromClient = stdIn.readLine().trim();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement