You could try something like this:
ProcessBuilder pb = new ProcessBuilder();
pb.redirectInput(new FileInputStream(new File(infile));
pb.redirectOutput(new FileOutputStream(new File(outfile));
pb.command(cmd);
pb.start().waitFor();
More Related Contents:
- Redirect stdin and stdout in Java
- How to redirect system.out.print statements to web page in JSP
- How to make pipes work with Runtime.exec()?
- How to execute cmd commands via Java
- How to execute command with parameters?
- Executing a Java application in a separate process
- How can I “intercept” Ctrl+C in a CLI application?
- Why do I get the “Unhandled exception type IOException”?
- How do I launch a completely independent process from a Java program?
- Redirect console output to string in Java
- log4j redirect stdout to DailyRollingFileAppender
- Running Shell commands though java code on Android?
- Run Java class file from PHP script on a website
- Why does ‘java -version’ go to stderr?
- Eclipse reading stdin (System.in) from a file
- How to add a timeout value when using Java’s Runtime.exec()?
- Redirect Runtime.getRuntime().exec() output with System.setOut();
- run shell command from java
- java.util.scanner throws NoSuchElementException when application is started with gradle run
- Why can’t we read one character at a time from System.in?
- Runtime.exec on argument containing multiple spaces
- Using Quotes within getRuntime().exec
- In Java, how can I redirect System.out to null then back to stdout again?
- Capturing contents of standard output in Java
- How to use Scanner to read silently from STDIN in Java?
- Why do System.err statements get printed first sometimes?
- How to use Pipe Symbol through exec in Java [duplicate]
- What’s the fastest way to read from System.in in Java?
- Snake game in Java but my restart button does not work
- Spring 3.2.x with Java 8