Commit | Line | Data |
---|---|---|
0af858cf SP |
1 | import com.google.gson.Gson; |
2 | ||
3 | import java.io.BufferedReader; | |
4 | import java.io.FileInputStream; | |
5 | import java.io.InputStream; | |
6 | import java.io.InputStreamReader; | |
7 | ||
71754579 | 8 | public class Region { |
0af858cf SP |
9 | private String continent; |
10 | private String pays; | |
11 | public Region(){ | |
12 | ||
13 | ||
14 | } | |
15 | @SuppressWarnings("SpellCheckingInspection") | |
16 | public void lectureOrigine(String continent, String pays){ | |
17 | Gson gson = new Gson(); | |
18 | Region r = new Region(); | |
19 | String contenu = ""; | |
20 | try{ | |
21 | InputStream flux = new FileInputStream(continent + ".txt"); | |
22 | InputStreamReader lecture=new InputStreamReader(flux); | |
23 | BufferedReader buff=new BufferedReader(lecture); | |
24 | String ligne; | |
25 | while ((ligne=buff.readLine())!=null){ | |
26 | contenu+=ligne; | |
27 | } | |
28 | buff.close(); | |
29 | } | |
30 | catch (Exception e){ | |
31 | System.out.println(e.toString()); | |
32 | } | |
33 | System.out.println("les information du pays" + pays +" du fichier est : "+contenu); | |
34 | // maintenant je veux deserialiser | |
35 | Origin coords3 = gson.fromJson(contenu,Origin.class); | |
36 | //Coordonnees co = gson.fromJson(json,Coordonnees.class); | |
37 | System.out.println("Resultat = " + coords3); | |
38 | } | |
71754579 | 39 | } |