I am currently trying to store the value of the PrintWriter OutputStream as a variable (string).
When the code is run at the moment, the line stdin.println("vol");
prints out volume information using Windows CMD.
I want to store the value that is printed in the console as a variable so it can be used later on.
Any help would be much appreciated!
Code:
package cmd_prompt;
import java.io.PrintWriter;
public class my_main {
public static void main(String[] args) {
String[] command =
{
"cmd",
};
Process p;
try {
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("vol");
stdin.close();
p.waitFor();
} catch (Exception e) {
e.printStackTrace();
}
}
}