|
How to send an Input to a Command |
|
|
This Java tip illustrates a method of sending an input to a command. Developer may use
this tip to sent input from the code. This is very helpful in cases when developer wants
send an input in a command prompt without the interruption of the user.
try {
// Execute command
String command = "cat";
Process child = Runtime.getRuntime().exec(command);
// Get output stream to write from it
OutputStream out = child.getOutputStream();
out.write("some text".getBytes());
out.close();
} catch (IOException e) {
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.