title: Write result from command line in file using Java
body: <p>I tried to run command line from Java code. </p>
  
  <pre><code>public void executeVcluto() throws IOException, InterruptedException {
      String command = "cmd /c C:\\Users\\User\\Downloads\\program.exe C:\\Users\\User\\Downloads\\file.txt 5 &gt;&gt; C:\\Users\\User\\Downloads\\result.txt";
      Process process = Runtime.getRuntime().exec(command);
      process.waitFor();
      if (process.exitValue() == 0) {
          System.out.println("Command exit successfully");
      } else {
          System.out.println("Command failed");
      }
  
  }
  </code></pre>
  
  <p>However, the file where output result should be written result.txt is not created. When I execute this command from cmd on windows the file is created and the result is written in it. I get Command exit successfully message. Could someone help me?</p>