Advertisement
Guest User

Untitled

a guest
May 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.io.*;
  4. import java.net.*;
  5.  
  6. public class Main {
  7.  
  8.  
  9. public static void main(String args[]) throws Exception {
  10. String clientSentence;
  11. String capitalizedSentence;
  12. ServerSocket welcomeSocket = new ServerSocket(6789);
  13.  
  14. while(true) {
  15. Socket connectionSocket = welcomeSocket.accept();
  16. BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
  17. DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
  18. clientSentence = inFromClient.readLine();
  19. capitalizedSentence = clientSentence.toUpperCase() + '\n';
  20. outToClient.writeBytes(capitalizedSentence);
  21. }
  22. }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement