package com.company; import java.io.*; import java.net.*; public class FileClient{ public static void main(String[] args){ try( Socket socket = new Socket("localhost", 8000);//Nawiızywanie po³ıczenia z serwerem InputStream is = socket.getInputStream();//pobieranie strumienia bajtowego WE FileOutputStream fos = new FileOutputStream(new File("clientFile.dat"));//strumieñ plikowy WY pracujıcy na bajtach ObjectInputStream ois = new ObjectInputStream(is) ){ System.out.println("Connected to server..."); System.out.println("File is downloading..."); Message msg = (Message) ois.readObject(); System.out.println(msg.toString()); fos.write(msg.getContent(),0, msg.getLenght()); fos.close(); System.out.println("File downloaded"); }catch(Exception e){ e.printStackTrace(); } } }