@SuppressWarnings({"InfiniteLoopStatement", "ResultOfMethodCallIgnored"})
    public static void main(String[] args) throws IOException {
        if(args.length!=2){
            System.out.println("Usage: prog_name <PORT> <PATH>");
            System.exit(1);
        }

        ServerSocket ssocket = new ServerSocket(Integer.parseInt(args[0]));
        String filePath = args[1];
        try {
            while (true) {
                Socket socket = ssocket.accept();
                InputStream in = socket.getInputStream();
                OutputStream out = socket.getOutputStream();
                byte[] received = new byte[BUFLEN];
                File file = new File(filePath);
                file.createNewFile();
                FileOutputStream fileStream = new FileOutputStream(filePath);

                int read=0;
                while(read!=-1) {
                    // receive
                    read = in.read(received);
                    if(read>0)
                        fileStream.write(received,0,read);
                }
                socket.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            ssocket.close();
        }
    }