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
| public void executer(File file) throws IOException {
IOManager.String2Consoles(IOManager.sep+"Exécution des commandes du fichier "+file.getName()+".");
String line;
String[] TCommands= IOManager.File2TString(file);
FenetreEditeurScripts.consoleJTA.setText(IOManager.sep+"Longueur de TCommands="+TCommands.length+"\n");
try{
for(int i=0;i<TCommands.length;i++) {
if(TCommands[i]!="" &&TCommands[i]!="\n") {
IOManager.String2Consoles(IOManager.sep+"Execution de la "+i+"eme commande de "+file.getName()+" : "+TCommands[i]);
this.p = Runtime.getRuntime().exec(TCommands[i].substring(0, TCommands[i].length()-1));
BufferedReader input =
new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null)
{
FenetreEditeurScripts.outputJTA.append(line+"\n");
}
input.close();
}
}
IOManager.String2Consoles(IOManager.sep+"Execution des commandes de "+file.getName()+" terminee.");
}
catch (Exception e) {
e.printStackTrace();
IOManager.String2Consoles(IOManager.sep+"Erreur dans la methode executer() :"+e.toString());
}
} |
Partager