1 package com.thaiopensource.util; 2 3 import java.io.InputStream ; 4 import java.io.IOException ; 5 import java.util.Properties ; 6 import java.util.MissingResourceException ; 7 8 public class Version { 9 private Version() { } 10 11 public static String getVersion(Class cls) { 12 InputStream in = cls.getResourceAsStream("resources/Version.properties"); 13 if (in != null) { 14 Properties props = new Properties (); 15 try { 16 props.load(in); 17 String version = props.getProperty("version"); 18 if (version != null) 19 return version; 20 } 21 catch (IOException e) { } 22 } 23 throw new MissingResourceException ("no version property", 24 cls.getName(), 25 "version"); 26 } 27 28 } 29 | Popular Tags |