001    package com.thaiopensource.util;
002    
003    import java.io.InputStream;
004    import java.io.IOException;
005    import java.util.Properties;
006    import java.util.MissingResourceException;
007    
008    public class Version {
009      private Version() { }
010    
011      public static String getVersion(Class cls) {
012        InputStream in = cls.getResourceAsStream("resources/Version.properties");
013        if (in != null) {
014          Properties props = new Properties();
015          try {
016            props.load(in);
017            String version = props.getProperty("version");
018            if (version != null)
019              return version;
020          }
021          catch (IOException e) { }
022        }
023        throw new MissingResourceException("no version property",
024                                           cls.getName(),
025                                           "version");
026      }
027    
028    }