List of usage examples for java.lang ProcessBuilder redirectError
public Redirect redirectError()
From source file:Main.java
public static void main(String[] args) { // create a new list of arguments for our process String[] list = { "notepad.exe", "test.txt" }; // create the process builder ProcessBuilder pb = new ProcessBuilder(list); try {//from w w w .ja v a 2s . c om ProcessBuilder.Redirect re = pb.redirectError(); pb.start(); System.out.println(re); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Test.java
public static void main(String[] args) throws Exception { File commands = new File("C:/Projects/ProcessCommands.txt"); File output = new File("C:/Projects/ProcessLog.txt"); File errors = new File("C:/Projects/ErrorLog.txt"); ProcessBuilder pb = new ProcessBuilder("cmd"); System.out.println(pb.redirectInput().toString()); System.out.println(pb.redirectOutput().toString()); System.out.println(pb.redirectError().toString()); pb.redirectInput(commands);/*from w w w . j a v a 2 s .c om*/ pb.redirectError(errors); pb.redirectOutput(output); System.out.println(pb.redirectInput().toString()); System.out.println(pb.redirectOutput().toString()); System.out.println(pb.redirectError().toString()); pb.start(); }
From source file:xbdd.webapp.resource.feature.PrintPDF.java
public void generatePDF(final List<String> commands) throws IOException { final ProcessBuilder probuilder = new ProcessBuilder(commands); probuilder.redirectError(); probuilder.redirectOutput();// w w w. j av a 2 s. c o m probuilder.redirectInput(); final Process process = probuilder.start(); try { process.waitFor(); } catch (final InterruptedException e) { e.printStackTrace(); } process.destroy(); }