我需要通过java访问节点上的控制台如何做到这一点?
public class Comando {
public static void main(String[] args) {
String comando = "C:\\Program Files\\nodejs\\node.exe";
try {
Process process = Runtime.getRuntime().exec(comando);
OutputStream stdin = process.getOutputStream ();
InputStream stderr = process.getErrorStream ();
InputStream stdout = process.getInputStream ();
stdin.write("1+2".getBytes());
stdin.flush();
// System.out.print(stdout.read());
stdin.close();
System.out.print(stdout.read());
//BufferedReader reader = new BufferedReader (new InputStreamReader(stdout));
//BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdin));
// writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}