Created
December 26, 2018 18:39
-
-
Save a18simongv/bc9864a21bf6c480a888ba71fbeb43bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package processBuilderCase; | |
import java.io.File; | |
public class ProcessBuilderExample { | |
public static void main(String[] args) { | |
//create the command | |
String cmd = "ps"; | |
try { | |
ProcessBuilder pb = new ProcessBuilder(cmd); | |
//redirect the output to a new file named output.txt | |
pb.redirectOutput(new File("output.txt")); | |
pb.start();//execute the command | |
} catch(Exception ex) { | |
ex.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment