#vulnerable code 
                                private void savePolicyFile(String text) {
        try {
            FileOutputStream fos = new FileOutputStream(filePath);
            fos.write(text.getBytes());
            fos.close();
        } catch (IOException e) {
            e.printStackTrace();
            throw new Error("IO error occurred");
        }
    } 
                            #location 6 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                private void savePolicyFile(String text) {
        try (FileOutputStream fos = new FileOutputStream(filePath)) {
            IOUtils.write(text, fos, Charset.forName("UTF-8"));
        } catch (IOException e) {
            e.printStackTrace();
            throw new Error("Policy save error");
        }
    }