Questions marquées «runtime.exec»


4
Comment faire fonctionner les tuyaux avec Runtime.exec ()?
Considérez le code suivant: String commandf = "ls /etc | grep release"; try { // Execute the command and wait for it to complete Process child = Runtime.getRuntime().exec(commandf); child.waitFor(); // Print the first 16 bytes of its output InputStream i = child.getInputStream(); byte[] b = new byte[16]; i.read(b, 0, b.length); …
104 java  exec  runtime.exec 

4
Différence entre ProcessBuilder et Runtime.exec ()
J'essaie d'exécuter une commande externe à partir du code java, mais il y a une différence que j'ai remarquée entre Runtime.getRuntime().exec(...)et new ProcessBuilder(...).start(). Lors de l'utilisation Runtime: Process p = Runtime.getRuntime().exec(installation_path + uninstall_path + uninstall_command + uninstall_arguments); p.waitFor(); exitValue est 0 et la commande se termine ok. Cependant, avec ProcessBuilder: …

En utilisant notre site, vous reconnaissez avoir lu et compris notre politique liée aux cookies et notre politique de confidentialité.
Licensed under cc by-sa 3.0 with attribution required.