1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.metricshub.wbem.sblim.cimclient.internal.cim;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 import java.io.FileNotFoundException;
47 import java.io.IOException;
48 import java.io.InputStream;
49 import java.util.Properties;
50
51
52
53
54
55 public class CIMVersion {
56 private static String PRODUCT_NAME = "n/a";
57
58 private static String VERSION = "n/a";
59
60 private static String COPYRIGHT = "n/a";
61
62 private static String BUILDDATE = "n/a";
63
64 private static String BUILDTIME = "n/a";
65
66 static {
67 Properties properties = new Properties();
68 InputStream versionIS = null;
69 try {
70 versionIS = CIMVersion.class.getClassLoader().getResourceAsStream("org/sblim/cimclient/version.txt");
71 properties.load(versionIS);
72 PRODUCT_NAME = properties.getProperty("PRODUCTNAME");
73 VERSION = properties.getProperty("VERSION");
74 COPYRIGHT = properties.getProperty("COPYRIGHT");
75 BUILDDATE = properties.getProperty("BUILDDATE");
76 BUILDTIME = properties.getProperty("BUILDTIME");
77 } catch (FileNotFoundException e) {
78 System.out.println("Error: Could not open version.txt");
79 } catch (IOException e) {
80 System.out.println("Error while reading version.txt");
81 } finally {
82 if (versionIS != null) {
83 try {
84 versionIS.close();
85 } catch (IOException e) {
86
87 }
88 }
89 }
90 }
91
92
93
94
95
96
97 public static String getBuildDate() {
98 return BUILDDATE;
99 }
100
101
102
103
104
105
106 public static String getBuildTime() {
107 return BUILDTIME;
108 }
109
110
111
112
113
114
115 public static String getCopyright() {
116 return COPYRIGHT;
117 }
118
119
120
121
122
123
124 public static String getProductName() {
125 return PRODUCT_NAME;
126 }
127
128
129
130
131
132
133 public static String getVersion() {
134 return VERSION;
135 }
136
137
138
139
140
141
142 @Override
143 public String toString() {
144 return (PRODUCT_NAME + "\n" + VERSION + "\n" + COPYRIGHT + "\n" + BUILDDATE + "\n" + BUILDTIME);
145 }
146
147
148
149
150
151
152 public static void main(String[] args) {
153 System.out.println(new CIMVersion());
154 }
155 }