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

📄 filesetting.java

📁 CoolFace是基于jxta的P2P系统
💻 JAVA
字号:
package com.cn.darkblue.util;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class FileSetting {
	private static final Log log = LogFactory.getLog(FileSetting.class);
    private  Properties properties = null;	
	private String propFile;
	public void init(String fileName){	
		propFile = fileName;
		String path = propFile;
		try {
			InputStream is = new FileInputStream(path);
			properties = new Properties();
			properties.load(is);
			is.close();
		} catch (Exception e) {
			log.error(e.getMessage());
		}
	}

	public String getParam(String key){
		return properties.getProperty(key);
	}
	
	public void setParam(String key, String value) {
		try {
			InputStream is = new FileInputStream( propFile);
			Properties properties = new Properties();
			properties.load(is);
			properties.setProperty(key, value);
			is.close();
			OutputStream out = new FileOutputStream(propFile);
			properties.save(out, "save");
			out.close();
		} catch (Exception e) {
			log.error(e.getMessage());
		}
	}

}

⌨️ 快捷键说明

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