Greeings all
Im trying to excute a command from Java and direct the output to the main output screen or to another file .... can you please help with this ? can I use filewriter for this ?
Here is my code....
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
public class RunCommand {
private static boolean str;
public static void main(String args[]) throws IOException {
File dir = new File("c:\\Redalert");
Process proc = Runtime.getRuntime().exec("cmd /c start dir", null, dir);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream()));
// FileWriter fw = new FileWriter("c:\\output.txt");
while (str = stdInput.readLine() != null) {
System.out.println(str);
}
}
}