Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 import java.io.BufferedReader ; 2 import java.io.IOException ; 3 import java.io.InputStream ; 4 import java.io.InputStreamReader ; 5 6 7 15 public class version { 16 public static final String SAPIA_VERSION = "sapia.version"; 17 18 public static void main(String [] args) { 19 InputStream is = findVersionStream("/META-INF/" + SAPIA_VERSION); 20 21 if (is == null) { 22 is = findVersionStream(SAPIA_VERSION); 23 } 24 25 if (is == null) { 26 System.out.println("Could not find " + SAPIA_VERSION + 27 " resource; version information could not be provided."); 28 } else { 29 processVersionStream(is); 30 } 31 } 32 33 private static void processVersionStream(InputStream is) { 34 BufferedReader reader = null; 35 36 try { 37 reader = new BufferedReader (new InputStreamReader (is)); 38 39 String line; 40 System.out.println(); 41 42 while ((line = reader.readLine()) != null) { 43 System.out.println(line); 44 } 45 46 System.out.println(); 47 } catch (IOException e) { 48 e.printStackTrace(); 49 } finally { 50 if (reader != null) { 51 try { 52 reader.close(); 53 } catch (Throwable t) { 54 } 56 } 57 } 58 } 59 60 private static InputStream findVersionStream(String resource) { 61 InputStream is = Thread.currentThread().getContextClassLoader() 62 .getResourceAsStream(resource); 63 64 if (is == null) { 65 is = ClassLoader.getSystemResourceAsStream(resource); 66 } 67 68 if (is == null) { 69 is = version.class.getResourceAsStream(resource); 70 } 71 72 return is; 73 } 74 } 75
| Popular Tags
|