Code example for JarFile

Methods: getEntry, getInputStream

0
    private String getSubsonicBuildNumber() {
        File war = new File(getWar());
        InputStream in = null;
        try { 
            if (war.isFile()) {
                JarFile jar = new JarFile(war);
                ZipEntry entry = jar.getEntry("WEB-INF\\classes\\build_number.txt");
                if (entry == null) {
                    entry = jar.getEntry("WEB-INF/classes/build_number.txt");
                } 
                in = jar.getInputStream(entry);
            } else { 
                in = new FileInputStream(war.getPath() + "/WEB-INF/classes/build_number.txt");
            } 
            return IOUtils.toString(in);
 
        } catch (Exception x) {
            System.err.println("Failed to resolve build number from WAR: " + war);
            x.printStackTrace();
            return null; 
        } finally {