Advertisement
Josif_tepe

Untitled

Apr 22nd, 2021
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.io.PrintWriter;
  5. import java.net.Socket;
  6. import java.net.UnknownHostException;
  7.  
  8. public class Client {
  9.     public static void main(String[] args) {
  10.         try {
  11.             System.out.println("Najaveni sme");
  12.             Socket socket = new Socket("localhost", 4567);
  13.             BufferedReader userInput = new BufferedReader(new InputStreamReader(System.in));
  14.             System.out.println("Napisi poraka: ");
  15.             String poraka = userInput.readLine();
  16.             PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
  17.             out.println(poraka);
  18.             BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
  19.             System.out.println(input.readLine());
  20.  
  21.         }
  22.        catch (Exception e) {
  23.  
  24.        }
  25.  
  26.  
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement