Générer la sortie d'une commande dos dans un fichier texte

miagiste84 Messages postés 2 Date d'inscription mardi 9 décembre 2008 Statut Membre Dernière intervention 16 mars 2009 - 16 mars 2009 à 17:26
Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 - 17 mars 2009 à 19:55
Bonjour,

j'ai utilisé l'étiqueteur tree tagger sur des textes.

voilà le code

Code :
package cvanalysis;
import java.io.*;
publicclass TreeTagger {
public TreeTagger(File file)throws IOException {
final FileInputStream input = new FileInputStream(file);
String fileAbsolutePath = file.getAbsolutePath();
String name=file.getName();
TreeTagger treeTaggerObj=new TreeTagger(null);
treeTaggerObj.analyser_morph(file);
treeTaggerObj.PrintInFile(name);
}
publicvoid analyser_morph(File f){
// File f=null;

//final FileInputStream input = new FileInputStream(f);
String path= f.getAbsolutePath();
String name="sortie.txt";
String ch="C:\\WINDOWS\\System32\\cmd.exe";
String ch1= "C:\\treetagger";
String ch2="tokenise-fr.pl"+path+"| bin\tree-tagger.exe lib\french.par -lemma -token -sgml >"+name ;
 
try{
 
Process p= Runtime.getRuntime().exec(new String[]{"cmd", "/c",ch});
Process p1= Runtime.getRuntime().exec(new String[]{"cmd", "/c", ch1});
Process p2=Runtime.getRuntime().exec(new String[]{"cmd", "/c", ch2});
wait(5);
 
}
catch(Exception e){System.out.println(e);}
}
}
 
Maintenant je veux récupérer la sortie de la commande dans un fichier texte.

Si quelqu'un de vous a une idée n'hésitez pas de me passer

Je vous attends.

Merci d'avance

1 réponse

Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 111
17 mars 2009 à 19:55
Salut,

exploite les flux de la classe Process ils sont fait pour ça.

------------------------------------
"On n'est pas au resto : ici on ne fait pas dans les plats tout cuits ..."

OoWORAoO
0
Rejoignez-nous