[Runtime] Rediriger la sortie d'un processus
j'ai un probleme pour rediriger ma sortie d'ecran, voici mon code qui marche bien sous windows et qui fait appel à une application externe NPI.exe avec un argument d'entrée arg1 :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
String[] T = {
"NPI.exe",
"arg1"
};
try {
Process process = Runtime.getRuntime().exec(T);
BufferedReader ds = new BufferedReader(new InputStreamReader(process.getInputStream()));
String lineCourante = ds.readLine();
while (lineCourante != null) {
System.out.println(lineCourante);
lineCourante = ds.readLine();
}
} catch (IOException ioe){
System.out.println("erreur de redirection !!"+ioe);
} |
et lorsque je suis sous linux sa marche mais n'affiche rien voici le code adapté à linux:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
String[] T = {
"./NPI.exe",
"arg1"
};
try {
Process process = Runtime.getRuntime().exec(T);
BufferedReader ds = new BufferedReader(new InputStreamReader(process.getInputStream()));
String lineCourante = ds.readLine();
while (lineCourante != null) {
System.out.println(lineCourante);
lineCourante = ds.readLine();
}
} catch (IOException ioe){
System.out.println("erreur de redirection !!"+ioe);
} |
merci de me dire ce qui ne va pas dans mon code