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

Android Studio – Unit testing. java.lang.NullPointerException

everyone! I am writing unit tests for the mobile app. But I have an error that I don't know how to solve. The error has the following form: java.lang.NullPointerException at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:841) at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:806) at androidx.appcompat.app.AppCompatDelegateImpl.findViewById(AppCompatDelegateImpl.java:630) at androidx.appcompat.app.AppCompatActivity.findViewById(AppCompatActivity.java:223) at com.example.projectMP3.SplashScreenActivityTest.testLaunchOfNewActivity(SplashScreenActivityTest.java:14) at…

VIEW QUESTION
Back To Top
Search