Есть такой код, я передаю на вход два параметра и получаю в консоле результат работы этого метода, мне необходимо сохранить результат в переменную как это сделать правильно ? Просьба помидорами не кидаться, буду рад любой помощи. Результат работы метода скрин 
 
public static String activation(String serialNumber, String keyName) throws IOException, InterruptedException, SQLException {
        LocalDate futureDate = LocalDate.now().plusMonths(12);
        String formattedDate = futureDate.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
        String[] command =
                {
                        "cmd",
                };
        Process p = Runtime.getRuntime().exec(command);
        new Thread(new SyncPipe(p.getErrorStream(), System.err)).start();
        new Thread(new SyncPipe(p.getInputStream(), System.out)).start();
        PrintWriter stdin = new PrintWriter(p.getOutputStream());
        stdin.println("C:\\tdes_ecb.exe " + serialNumber + " " + keyName + " " + formattedDate);
        stdin.close();
        int returnCode = p.waitFor();
        String code = Integer.toString(returnCode);
        return code;
    }
    static class SyncPipe implements Runnable {
        public SyncPipe(InputStream istrm, OutputStream ostrm) {
            istrm_ = istrm;
            ostrm_ = ostrm;
        }
        public void run() {
            try {
                final byte[] buffer = new byte[1024];
                for (int length = 0; (length = istrm_.read(buffer)) != -1; ) {
                    ostrm_.write(buffer, 0, length);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        private final OutputStream ostrm_;
        private final InputStream istrm_;
    }