KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thaiopensource > util > Version


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