J’ai décidé de faire plus simple, je m’explique dans les fichiers texte à ma dispositions il y ça :
- Sailors aboard USS Carl Vinson prepare to man the rails as the ship arrives in Pearl Harbor.
Du coup j’ai essayé de faire la regex suivante : "[a-zA-Z]" mais elle ne marche absolument pas et je vois pas pourquoi donc si une personne à une solution ou une idée
public class Main {
public static void main(String[] args) throws IOException {
String photographer = "";
String photo_url = "";
String Taken_Date = "";
String titre = "";
String description = "";
String tags = "";
String ligne;
String regex = "[a-zA-Z]";
CSVWriter writer = new CSVWriter(new FileWriter("E:\\Apollo_11.csv"));
File repertoire = new File("E:\\53_Txt");
File[] files = repertoire.listFiles();
String[] titres = {"1_Index_INTERNE","2_Mission_PUBLIC","3_Reference_Nasa_avec_Titre_INTERNE","4_Reference_Nasa_INTERNE",
"5_Date_prise_de_vue/Traitement_de_l'image_PUBLIC","6_Date_de_traitement_de_l'image_PUBLIC",
"7_Reference_Galaxy_PUBLIC","8_Reference_Nasa_ou_FL/Galaxy_INTERNE","9_Reference_FL_INTERNE",
"10_Titre_PUBLIC","11_Description_PUBLIC",
"12_Wikipedia_Infos_about_PUBLIC","13_Mots_cles_PUBLIC",
"14_Taille_MB_PUBLIC","15_Width_PUBLIC","16_Height_PUBLIC","17_Depth_PUBLIC","18_Dpi_PUBLIC",
"19Format_PUBLIC","20_Orientation_PUBLIC","21_Focal_Length_PUBLIC","22_Aperture_PUBLIC","23_Exposure_PUBLIC",
"24_Sensitivity_PUBLIC","25_Manufacture_PUBLIC","26_Model_PUBLIC","27_User_Comment_INTERNE",
"ProprietairePublic","29_OPTION_1","30_OPTION_2","31_OPTION_3"};
writer.writeNext(titres);
for (File file : files) {
String name_File = (file.getName() != null) ? file.getName().substring(0,file.getName().indexOf('.')) : "";
System.out.println("\n"+name_File);
try {
InputStream ips = new FileInputStream(file);
InputStreamReader ipsr = new InputStreamReader(ips);
BufferedReader br = new BufferedReader(ipsr);
while ((ligne = br.readLine()) != null) {
if(ligne.startsWith("Photographer : ")) {
System.out.println(ligne);
photographer = ligne.substring(15);
}else if (ligne.startsWith("Photo URL")) {
System.out.println("Photo URL : " + ligne.substring(52,61));
photo_url = ligne.substring(52,61);
}else if(ligne.startsWith("Taken Date")) {
System.out.println(ligne);
Taken_Date = ligne.substring(12);
}else if(ligne.startsWith(regex)) {
System.out.println("Titre : " + ligne);
titre = ligne.substring(0);
}else if (ligne.startsWith("Ap")) {
System.out.println("Description : " + ligne);
description = ligne.substring(0);
}else if(ligne.startsWith("N",1)) {
System.out.println("Tags : " + ligne.substring(0));
tags = ligne.substring(0);
}
}
br.close();
}catch (Exception e) {
System.out.println(e.toString());
}
}
writer.close();
}
}