import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.util.ArrayList; import com.google.gson.Gson; public class Mainconsole { ArrayList placeList; public Mainconsole() { this.placeList = new ArrayList<>(); this.readFile(); } public void readFile() { try { tryReadFile(); } catch (FileNotFoundException e) { System.err.println("Hiba! A fájl nem található!"); } } public void tryReadFile() throws FileNotFoundException { Gson gson = new Gson(); FileReader fr = new FileReader("database.json"); BufferedReader br = new BufferedReader(fr); Place[] data = gson.fromJson(br, Place[].class); for(Place place : data) { placeList.add(place); System.out.println(place.name); } } }