Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Bill Howell   on Jul 02 In Java Category.

  
Question Answered By: Debbie Reyes   on Jul 02


try {
// Execute command
String command = "ls";
Process child = Runtime.getRuntime().exec(command);

// Get input stream to read from it
InputStream in = child.getInputStream();
int c;
while ((c = in.read()) != -1) {
process((char)c);
}
in.close();
catch  (IOException e) {
}


sending input

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) {
}

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Running an executable Or get search suggestion and latest updates.


Tagged: