bonjour Joel.Drigo,
voici le code de ma méthode EXECUTION. en effet elle fait appel a un shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| package mygribwindow;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author moi
*/
public class Execution {
/**
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
Runtime runtime = Runtime.getRuntime();
String[] cmd = { "/bin/sh", "-c", "bash /Users/moi/Desktop/concatenator\\ basic\\ 48h.sh" };
final Process process = runtime.exec(cmd);
// Consommation de la sortie standard de l'application externe dans un Thread separe
new Thread() {
@Override
public void run() {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = "";
try {
while((line = reader.readLine()) != null) {
// Traitement du flux de sortie de l'application si besoin est
}
} finally {
reader.close();
}
} catch(IOException ioe) {
}
}
}.start();
// Consommation de la sortie d'erreur de l'application externe dans un Thread separe
new Thread() {
@Override
public void run() {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String line = "";
try {
while((line = reader.readLine()) != null) {
// Traitement du flux d'erreur de l'application si besoin est
}
} finally {
reader.close();
}
} catch(IOException ioe) {
}
}
}.start();
}
} |
à comprendre ta réponse je dois rentrer dans ma première méthode :
Execution.main( "/bin/sh", "-c", "bash /Users/moi/Desktop/concatenator\\ basic\\ 48h.sh" );
ou
Execution.main(new String[] cmd = { "/bin/sh", "-c", "bash /Users/moi/Desktop/concatenator\\ basic\\ 48h.sh" });
Partager