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

📄 configurationmanager.java

📁 一个远程控制的java测试程序源代码.转于网上
💻 JAVA
字号:
/*
 * @(#)ConfigurationManager.java 1.00 2005-7-19
 *
 * Copyright 2005 BeanSoft Studio. All rights reserved.
 * PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package studio.beansoft.remotecontrol;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;

import studio.beansoft.util.logging.Logger;

/**
 * 
 * ConfigurationManager loads and save configuration from a properties file. 
 * 
 * Chinese documents:
 * 属性文件中的配置信息的加载和保存类.
 * 
 * @author BeanSoft
 * @version 1.00 2005-9-9
 */
public class ConfigurationManager {
	/** Configuration file path was: conf/remote_control.properties */
	private static String confFilePath = "conf" + File.separator
			+ "remote_control.properties";
	
	/** Logger */
	private static Logger logger = Logger.getLogger(ConfigurationManager.class);

	private ConfigurationManager() {
	}

	/**
	 * Read configuration from the properties file.
	 * 
	 * @return a Properties object
	 */
	public static Properties getConfiguration() {
		Properties props = new Properties();
		try {

			FileInputStream in = new FileInputStream(confFilePath);
			props.load(in);

			in.close();
		} catch (Exception e) {
			logger.fatal("Unable to read configruation file, make sure there is a file:"
					+ confFilePath);
		}
		return props;
	}

	/**
	 * 
	 * Save configuration to the properties file.
	 * 
	 * @param props
	 *            Properties to save
	 * @return returns true if successed
	 */
	public static boolean saveConfiguration(Properties props) {
		if (props == null)
			return false;
		try {
			FileOutputStream out = new FileOutputStream(confFilePath);

			props.store(out, "Remote Control Configuration File");

			out.close();

			return true;
		} catch (Exception e) {
			logger.error("Unable to save configruation file, make sure there is a writable file:"
					+ confFilePath);
		}
		return false;
	}

}

⌨️ 快捷键说明

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