package greed;

import greed.util.Debug;

import java.io.*;

/**
 * @author WuCY
 */
public class AppInfo {
    private final static String APP_NAME = "Greed";
    private static String VERSION = null;

    public static String getAppName() {
        return APP_NAME;
    }

    public static String getVersion() {
        if (VERSION == null) {
            try {
                VERSION = Debug.developmentMode
                        ? readVersionFromStream(new FileInputStream("version"))
                        : readVersionFromStream(AppInfo.class.getResourceAsStream("/version"));
            } catch (FileNotFoundException e) {}
        }
        return VERSION;
    }

    private static String readVersionFromStream(InputStream is) {
        BufferedReader reader = null;
        try {
            reader = new BufferedReader(new InputStreamReader(is));
            return reader.readLine().trim();
        }
        catch (NullPointerException e) {}
        catch (IOException e) {}
        finally {
            if (reader != null)
                try { reader.close(); } catch (IOException e) {}
        }
        return "[UNKNOWN]";
    }

    public static void main(String[] args) {
        System.out.println(getVersion());
    }
}

@@ -733,24 +733,92 @@
 tream is) %7B%0A
+        if (is == null) %7B%0A            return %22%5BUNKNOWN%5D%22;%0A        %7D%0A
         Buff
@@ -984,50 +984,8 @@
   %7D%0A
-        catch (NullPointerException e) %7B%7D%0A
     

handle null instead of using NullPointerException.