Code example for Properties

Methods: getProperty, loadFromXML

0
        String crcString = Long.toHexString(crc32).toUpperCase();
        InputStream inConfig = null;
        if((inConfig = PSXperiaTool.class.getResourceAsStream("/resources/patches/" + crcString + "/config.xml")) == null){
            throw new FileNotFoundException("Cannot find config for this APK (CRC32: " + crcString + ")");
        } 
        Properties config = new Properties();
        config.loadFromXML(inConfig);
        inConfig.close();
        Logger.info( 
                "Identified " + config.getProperty("game_name", "Unknown Game") +
                        " " + config.getProperty("game_region") +
                        " Version " + config.getProperty("game_version", "Unknown") +
                        ", CRC32: " + config.getProperty("game_crc32", "Unknown")
        ); 
        if(config.getProperty("valid", "yes").equals("no"))
            throw new UnsupportedOperationException("This APK is not supported.");
        Logger.verbose("Copying config files."); 
        FileUtils.copyInputStreamToFile(PSXperiaTool.class.getResourceAsStream("/resources/patches/" + crcString + "/config.xml"), new File(mOutputDir, "/config/config.xml"));
        FileUtils.copyInputStreamToFile(PSXperiaTool.class.getResourceAsStream("/resources/patches/" + crcString + "/filelist.txt"), new File(mOutputDir, "/config/filelist.txt"));
        FileUtils.copyInputStreamToFile(PSXperiaTool.class.getResourceAsStream("/resources/patches/" + crcString + "/stringReplacements.txt"), new File(mOutputDir, "/config/stringReplacements.txt"));
        String emulatorPatch = config.getProperty("emulator_patch", "");
        String gamePatch = config.getProperty("iso_patch", "");
        if(!gamePatch.equals("")){
            FileUtils.copyInputStreamToFile(PSXperiaTool.class.getResourceAsStream("/resources/patches/" + crcString + "/" + gamePatch), new File(mOutputDir, "/config/game-patch.bin"));
        } 
        if(!emulatorPatch.equals("")){
            FileUtils.copyInputStreamToFile(PSXperiaTool.class.getResourceAsStream("/resources/patches/" + crcString + "/" + emulatorPatch), new File(mOutputDir, "/config/" + emulatorPatch));