#fixed code
                              public static void persist(File screenshot, JSONObject tree, File dest) throws FileNotFoundException, IOException,
      JSONException {
    IOUtils.copy(new StringReader(tree.toString(2)), new FileOutputStream(dest), "UTF-8");
  }
#vulnerable code 
                              public static void persist(File screenshot, JSONObject tree, File dest)
      throws FileNotFoundException, IOException, JSONException {
    System.out.println(screenshot.getAbsolutePath());
    FileWriter write = new FileWriter(dest);
    IOUtils.copy(new StringReader(tree.toString(2)), new FileOutputStream(dest), "UTF-8");
    System.out.println(dest.getAbsolutePath());
  } 
                            #location 4 
                            #vulnerability type RESOURCE_LEAK