skip to Main Content

How could I read from an empty json File,at the start of the program is it empty but later can be written

The read file is that: public ArrayList<Aventura> readFile(){ ArrayList<Aventura> aventures = new ArrayList<>(); try{ AventuraDAO aventuraDAO=new AventuraDAO(); AventuraManage aventuraManage=new AventuraManage(aventuraDAO); Gson g=new Gson(); JsonReader reader=new JsonReader(new FileReader("Files/adventures.json")); Aventura[] ave=g.fromJson(reader, Aventura[].class ); if (ave.length==0){ System.out.println("The file should be empty"); ArrayList<Aventura> aventures2…

VIEW QUESTION

Json – How to filter array based on selected item

I have an array of objects in an json file: [ { "department": "Sound Department", "subDepartments": [ "Supervising Sound Editor", "Dialog Editor", "Sound Designer", "Foley Artis", "Sound Recordist" ] }, { "department": "Camera Department", "subDepartments": [ "Camera Operator", "Second Assistant…

VIEW QUESTION
Back To Top
Search