systemconfigdata.java

来自「本代码是一个权限管理系统源代码」· Java 代码 · 共 103 行

JAVA
103
字号

/*
 * Created on 2007-4-30
 *
 * 
 * 
 */
 package com.seavision.PermissionManage.help;

import java.io.UnsupportedEncodingException;
import java.util.ResourceBundle;


/**
 * @author Administrator
 *
 * 
 * 
 */
public class SystemConfigData {

	private static String configFileName = "seavisionconfig";

	private static ResourceBundle bundle = null;

	static {
		try {

			bundle = ResourceBundle.getBundle(configFileName);

		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("没有找到配置文件:" + configFileName);
		}
	}

	public static String getConfig(String configName) {
		try {

			if (null != bundle && null != configName) {
				return bundle.getString(configName);
			} else {
				System.out.println("没有找到配置:" + configName);
				return null;
			}

		} catch (java.util.MissingResourceException e) {
			System.out.println("没有找到配置:" + configName);
			return null;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}

	}
	
	public static String getConfigGBK(String configName){
		String   strGBK   = "";
		try {
			String a = getConfig(configName);
			if(a != null && a.length() > 0)
				strGBK = new String(a.getBytes("iso-8859-1"),"GBK");
			
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return strGBK;
		
	}
	public static Integer getConfigInteger(String configName) {
		String value = getConfig(configName);
		
		return new Integer(value);
	}

	public static Long getConfigLong(String configName) {
		String value = getConfig(configName);

		return new Long(value);
	}

	public static Object getObjectInstance(String configName) {
		String className = SystemConfigData.getConfig(configName);
		try {
			if(null != className)
			return Class.forName(className).newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		};
		return null;
	}
	
	public static void main(String[] a){
		

	}

}

⌨️ 快捷键说明

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