X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FRegion.java;h=4fd0143e38a5d3c212af32e8399800ccd3acf9da;hb=d32288945980439f628eedc8a3fcfdde927dd415;hp=5a497004b5bcc84e414f535225fcd89432dd4658;hpb=717545790ab42973994ea583199b44573daa5ca6;p=Persons_Comparator.git diff --git a/src/Region.java b/src/Region.java index 5a49700..4fd0143 100644 --- a/src/Region.java +++ b/src/Region.java @@ -1,2 +1,38 @@ +import com.google.gson.Gson; + +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.InputStream; +import java.io.InputStreamReader; + public class Region { + private String continent; + private String pays; + + public Region() { + } + + @SuppressWarnings("SpellCheckingInspection") + public void lectureOrigine(String continent, String pays) { + Gson gson = new Gson(); + Region r = new Region(); + String contenu = ""; + try { + InputStream flux = new FileInputStream(continent + ".txt"); + InputStreamReader lecture = new InputStreamReader(flux); + BufferedReader buff = new BufferedReader(lecture); + String ligne; + while ((ligne = buff.readLine()) != null) { + contenu += ligne; + } + buff.close(); + } catch (Exception e) { + System.out.println(e.toString()); + } + System.out.println("les information du pays" + pays + " du fichier est : " + contenu); + // maintenant je veux deserialiser + Origin coords3 = gson.fromJson(contenu, Origin.class); + //Coordonnees co = gson.fromJson(json,Coordonnees.class); + System.out.println("Resultat = " + coords3); + } }