Config.java
2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
package org.emercit.config;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.awt.Toolkit;
import java.net.URL;
import org.apache.log4j.Logger;
public class Config {
static final Logger logger = Logger.getLogger(Config.class);
private Properties prop = new Properties();
private String regkey;
private String service;
private boolean proxyEnabled;
private String proxyServer;
private int proxyPort;
private String version;
public Config() {
InputStream input = null;
try {
input = new FileInputStream("szsterminal.properties");
prop.load(input);
this.regkey=String.valueOf(prop.getProperty("regkey"));
this.service=String.valueOf(prop.getProperty("service"));
this.proxyEnabled=Boolean.valueOf(prop.getProperty("proxyEnabled"));
this.proxyServer=String.valueOf(prop.getProperty("proxyServer"));
this.proxyPort=Integer.valueOf(prop.getProperty("proxyPort"));
//029d10ca-22c3-4303-8fc0-2d2c586990a1
this.version=String.valueOf(prop.getProperty("version"));
} catch (IOException ex) {
logger.error(ex.getMessage());
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
logger.error(e.getMessage());
}
}
}
}
public void Save() {
OutputStream output = null;
try {
output = new FileOutputStream("szsterminal.properties");
prop.setProperty("regkey", String.valueOf(this.regkey));
// prop.setProperty("service", String.valueOf(this.service));
prop.setProperty("proxyEnabled", String.valueOf(this.proxyEnabled));
prop.setProperty("proxyServer", String.valueOf(this.proxyServer));
prop.setProperty("proxyPort", String.valueOf(this.proxyPort));
prop.setProperty("version", String.valueOf(this.version));
prop.store(output, null);
} catch (IOException io) {
} finally {
if (output != null) {
try {
output.close();
} catch (IOException e) {
}
}
}
}
/*
* Get
*/
public String getRegKey() {
return this.regkey;
}
public String getService() {
return this.service;
}
public boolean getProxyEnabled() {
return this.proxyEnabled;
}
public String getProxyServer() {
return this.proxyServer;
}
public int getProxyPort() {
return this.proxyPort;
}
public String getVersion() {
return this.version;
}
/*
* Set
*/
public void setRegkey(String value){
this.regkey=value;
}
public void setService(String value){
this.service=value;
}
public void setProxyEnabled(boolean value){
this.proxyEnabled=value;
}
public void setProxyServer(String value){
this.proxyServer=value;
}
public void setProxyPort(int value){
this.proxyPort=value;
}
public void setVersion(String version) {
this.version=version;
}
}