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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Vector;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.parser.ParserDelegator;
public class tester extends HTMLEditorKit.ParserCallback{
//*****************************************************
FileWriter fw;
static BufferedWriter bw;
static PrintWriter pw;
//*****************************************************
InputStream ips;
InputStreamReader ipsr;
static BufferedReader br;
//******************************************************
static ParserDelegator parser;
//contructeur d'entrée.
public tester() throws IOException{
fw = new FileWriter("hassna.txt");
bw=new BufferedWriter(fw);
pw=new PrintWriter(bw);
}
//constructeur de sortie
public tester(File fichier) throws FileNotFoundException{
ips=new FileInputStream(fichier);
ipsr=new InputStreamReader(ips);
br=new BufferedReader(ipsr);
parser=new ParserDelegator();
}
//Méthode pour parser les objets br.
public static void parssage() throws IOException{
HTMLEditorKit.ParserCallback callback=new tester();
parser.parse(br, callback, true);
}
//la methode handleText qui sera appelée par la methode parse de la calasse ParserDelegator().
public void handleText(char []data,int pos){
pw.println(data);
System.out.println(data);
}
//Méthode pour lister tous les fichiers .tpl qui existe dans le repertoire templates
public static Vector<File> lister(){
File repertoire=new File("D:\\PFE\\modules");
File []list1 =repertoire.listFiles();
Vector<File> list4=new Vector<File>();
for(int i=0;i<list1.length;i++){
// System.out.println("mon repertoire module: "+list1[i].getName());
File []list2=list1[i].listFiles();
for(int j=0;j<list2.length;j++){
if(list2[j].isDirectory() && "templates".equals(list2[j].getName())){
// System.out.println("mon sous repertoire module: "+list2[j].getName());
File []list3=list2[j].listFiles();
for(int k=0;k<list3.length;k++){
//System.out.println(list3[k].getName());
if(list3[k].isFile() && list3[k].getName().contains(".tpl")){
list4.add(list3[k]);
}else if(list3[k].isDirectory()&& !(".svn".equals(list3[k].getName()))&&("inc_consult_anesth".equals(list3[k].getName())
|| "inc_examen".equals(list3[k].getName())
|| "inc_acc".equals(list3[k].getName()))){
File []list5=list3[k].listFiles();
for(int m=0;m<list5.length;m++){
list4.add(list5[m]);
}
}
}
}
}
}
return list4;
}
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
Vector<File> listeTPL=lister();
for(int i=0;i<listeTPL.size();i++){
tester fichier=new tester(listeTPL.elementAt(i));
parssage();
}
pw.close();
br.close();
}
} |
Partager