rendered paste bodyimport java.net.*;import java.io.*;public class KnockKnockServer { public static void main(String[] args) throws IOException { FileOutputStream out_file; // declare a file output object PrintStream p; // declare a print stream object Writer fw = null; // open socket ServerSocket serverSocket = null; try { serverSocket = new ServerSocket(4444); } catch (IOException e) { System.err.println("Could not listen on port: 4444."); System.exit(1); } // open socket end // wait for connections Socket clientSocket = null; try { clientSocket = serverSocket.accept(); } catch (IOException e) { System.err.println("Accept failed."); System.exit(1); } // end PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true); BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); FileOutputStream fos = null; try { //fis = new FileInputStream(args [0]); fos = new FileOutputStream(args[0]); int byte_; while ((byte_ = in.read()) != -1) fos.write(byte_); } catch (FileNotFoundException e) { System.out.println("File not found"); // Do other stuff related to that exception (if necessary). } catch (IOException e) { System.out.println("I/O Problem: " + e.getMessage()); // Do other stuff related to that exception (if necessary). } finally { if (in != null) try { in.close(); } catch (IOException e) { } if (fos != null) try { fos.close(); } catch (IOException e) { } } clientSocket.close(); serverSocket.close(); } }