⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 servercfg.java

📁 短信发送
💻 JAVA
字号:
/**
 * Created at Nov 23, 2008
 */
package com.jdev.net.config;

import java.io.InputStream;
import java.util.Properties;

import com.jdev.util.Debug;


/**
 * <p>Title: ServerCfg</p>
 * <p>Description: 服务器参数配置</p>
 * @author Lawrence
 * @version 1.0
 */
public class ServerCfg {

	private final static String module = ServerCfg.class.getName();
	private static int tcpPort = 6188;
	private static String url = "127.0.0.1";
	private static byte[] begin = {(char)3};
	private static byte[] end = {(char)4};
	private static String appType = "sms";
	
	public String getUrl() {
		return this.url;
	}
	
	public int getTcpPort() {
		return tcpPort;
	}
	
	public byte[] getBeginFlag() {
		return begin;
	}
	
	public byte[] getEndFlag() {
		return end;
	}
	
	public String getAppType() {
		return this.appType;
	}
	
	private void getConfig() {
		Debug.logVerbose("begin to read config file ", module);
		
		InputStream in = null;
		try {
			Properties prop = new Properties();
			in = getClass().getClassLoader().getResourceAsStream("config.properties");
			prop.load(in);
			
			String portStr = prop.getProperty("server.tcpPort");
			Debug.logVerbose("Server Tcp Port=" + portStr, module);
			tcpPort = Integer.parseInt(portStr.trim());

			String beginStr = prop.getProperty("protocol.begin");
			Debug.logVerbose("protocol begin flag=" + beginStr, module);
			begin = Integer.toHexString((char)Integer.parseInt(beginStr.trim())).getBytes();

			String endStr = prop.getProperty("protocol.end");
			Debug.logVerbose("protocol end flag=" + endStr, module);
			end = Integer.toHexString((char)Integer.parseInt(beginStr.trim())).getBytes();

			String urlStr = prop.getProperty("server.url");
			Debug.logVerbose("Server Tcp Url=" + urlStr, module);
			url = urlStr;
	
			String typeStr = prop.getProperty("app.type");
			Debug.logVerbose("app type=" + urlStr, module);
			appType = typeStr;
			
			in.close();
		}catch(Exception e){
			Debug.logError("config error:" + e, module);
		}
	}
	
	/**
	 * 
	 */
	public ServerCfg() {
		getConfig();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -