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
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pdfclasses;
/**
*
* @author xxxxx
*/
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class test {
/**
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws com.itextpdf.io.IOException, IOException {
PDFManager pdfManager = new PDFManager();
pdfManager.setFilePath("/Users/xxxxx/Desktop/FR-ENR-5.7-fr-FR.pdf");
File AIRAC = new File("/Users/xxxxx/Desktop/AIRAC.txt") ;
String text = pdfManager.toText();
File AIRAC2 = new File("/Users/xxxxx/Desktop/AIRAC-2.txt") ;
try (PrintWriter out = new PrintWriter(new FileWriter(AIRAC))) {
out.write(text) ; //écris dans le fichier
out.println();//fais un retour à la ligne dans le fichier
out.close();//Ferme le flux du fichier, sauvegardant ainsi les données.
} catch (IOException e) {
e.printStackTrace();
}
Scanner in = new Scanner(AIRAC); //scanne le fichier AIRAC
in.useDelimiter("FIR");
in.useDelimiter("ASFC");
while(in.hasNextLine()) {
String line = in.next();
System.out.println(line); // renvoie le resultat du delimiteur dans la console
try (PrintWriter out = new PrintWriter(new FileWriter(AIRAC2))) {
out.write(line) ; //écris dans le fichier AIRAC2
out.println();//fais un retour à la ligne dans le fichier
out.close();//Ferme le flux du fichier, sauvegardant ainsi les données.
}catch (IOException e) {
e.printStackTrace();
}
}
}
} |
Partager