output: #fixed code
                                  static void reportResult(final String file, final String name, final Histogram histogram)
              throws IOException {
          final String result = createSamplingReport(name, histogram);
          println(result);
  
          if (file != null) {
              final FileWriter writer = new FileWriter(file, true);
              try {
                  writer.write(result);
                  writer.write(System.getProperty("line.separator"));
              } finally {
                  writer.close();
              }
          }
      }
input: #vulnerable code 
                                  static void reportResult(final String file, final String name, final Histogram histogram)
              throws IOException {
          final String result = createSamplingReport(name, histogram);
          println(result);
  
          if (file != null) {
              final FileWriter writer = new FileWriter(file, true);
              writer.write(result);
              writer.write(System.getProperty("line.separator"));
              writer.close();
          }
      } 
                              #location 11 
                              #vulnerability type RESOURCE_LEAK