So far I came with this solution, but I wonder if there is more efficient way to do this. Pseudo-code:
public static void main(String args[]){
boolean FileNotFound = false;
FileReader file = new FileReader("path");
   try (BufferedReader bReader = new BufferedReader(file){
   //nothing to execute here
   }catch (FileNotFoundException e) {
      FileNotFound = true; 
      }
if (FileNotFound) {
//generate the file
 } 
}
 
    