title: Java Command Line Output
body: <p>I am using the following code to execute a command in java and getting the output:</p>
  
  <pre><code>String line;
          try {
              System.out.println(command);
              Process p = Runtime.getRuntime().exec(command);
              BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
              while ((line = input.readLine()) != null) {
                  print(line);
              }
              input.close();
          }
          catch (Exception ex) {
              ex.printStackTrace();
          }
  </code></pre>
  
  <p>However, apparently the command 'tree' and 'assoc' and others aren't actually their own programs that can be run through Java, rather they are coded in as parts of command prompt, so I cannot get the output. Is there actually any way to do this? Thank you</p>