#fixed code
                                public static void main(String[] args) throws Exception {

        InputStream in = XmlSpike.class.getResourceAsStream("Config.xml");

        Properties props = load(in);

        File file = new File("target/test-resources/props.xml");
        file.getParentFile().mkdirs();

        ByteArrayOutputStream propertiesxmlformat = new ByteArrayOutputStream();
        props.storeToXML(propertiesxmlformat, "test");
        String propsXmlString = propertiesxmlformat.toString();


        System.out.println("java xml properties format:" + propsXmlString);

        Properties props2 = new Properties();
        props2.loadFromXML(new FileInputStream(file));


        Properties props3 = load(new FileInputStream(file));

        props.store(System.out, "props");
        props2.store(System.out, "props2");
        props3.store(System.out, "props3");
    }
#vulnerable code 
                                public static void main(String[] args) throws Exception {
        SAXParserFactory factory = SAXParserFactory.newInstance();
        SAXParser parser = factory.newSAXParser();

        InputStream in = XmlSpike.class.getResourceAsStream("Config.xml");

        String input = convertStreamToString(in);

        System.out.println("input:\n" + input);

        StringWriter output = new StringWriter();
        PrintWriter pw = new PrintWriter(output);
        XmlToPropsHandler h = new XmlToPropsHandler(pw);
        parser.parse(new StringInputStream(input), h);
        pw.flush();

        System.out.println("output:\n" + output);

        File file = new File("target/test-resources/props.xml");
        file.getParentFile().mkdirs();


        Properties props = new Properties();
        props.load(new StringInputStream(output.toString()));

        ByteArrayOutputStream propertiesxmlformat = new ByteArrayOutputStream();
        props.storeToXML(propertiesxmlformat, "test");
        String propsXmlString = propertiesxmlformat.toString();

        
        System.out.println("java xml properties format:" + propsXmlString);

        boolean isJavaProp = propsXmlString.contains("http://java.sun.com/dtd/properties.dtd");
        
        System.out.println("isJavaProp: " + isJavaProp);
    } 
                            #location 24 
                            #vulnerability type RESOURCE_LEAK