Config.java 2.97 KB
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;
	}
	

}