SHARE
TWEET

Untitled

a guest Nov 16th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. new Thread(new Runnable() {
  2.             public void run() {
  3.                 try {
  4.                     try {
  5.                         ServerSocket serverSocket = new ServerSocket(5555);
  6.                         System.out.println("ServerSocket awaiting connections...");
  7.                         Socket socket = serverSocket.accept();
  8.                         System.out.println("Connection from " + socket + "!");
  9.  
  10.                         InputStream inputStream = socket.getInputStream();
  11.                         ObjectInputStream objectInputStream = new ObjectInputStream(inputStream);
  12.  
  13.                         List<File> listOfMessages = (List<File>) objectInputStream.readObject();
  14.                         System.out.println("Received [" + listOfMessages.size() + "] files from: " + socket);
  15.                         listOfMessages.forEach((file) -> System.out.println("File recieved: " + file.getName()));
  16.  
  17.                         serverSocket.close();
  18.                         socket.close();
  19.                     } catch (IOException | ClassNotFoundException e) {
  20.                     }
  21.                 } catch (Exception e) {
  22.                 }
  23.             }
  24.         }).start();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top