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); Places placeData = gson.fromJson(br, Places.class); for(Place place : placeData.fishingspots) { placeList.add(place); } } }