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

📄 filepropenvsettings.java

📁 JRemoteControl is a simple Java&#8482 driven bluetooth remote control.It allows you to initiate virt
💻 JAVA
字号:
/* * JRemCntl - Copyright (C) 2007 Filippo Di Vattimo <fildiv@gmail.com> * See COPYING */package fildiv.jremcntl.server.core;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.util.Properties;import fildiv.jremcntl.common.core.JRemRuntimeException;import fildiv.jremcntl.common.util.JRemUtils;public class FilePropEnvSettings implements Settings {		private Properties p = null;	private String propFilePath = null;	private String propDescription = null;	public FilePropEnvSettings(String propFilePath, String configName) {			if (propFilePath == null)			throw new IllegalArgumentException();				this.propFilePath = propFilePath;		this.propDescription = JRemUtils.safeString(configName);				p = new Properties();				InputStream is = null;				try {			is = new FileInputStream(propFilePath);						p.load(is);					} catch(Exception e) {			throw new JRemRuntimeException("Unable to load : " + propFilePath, e);		} finally {			try {				if (is != null)					is.close();			} catch (IOException e) {				//Ignored			}					}	}	private boolean toBoolean(String value) {		if ("true".compareToIgnoreCase(value) == 0)			return true;				if ("false".compareToIgnoreCase(value) == 0)			return false;				int intValue = Integer.parseInt(value);		return intValue != 0;	}	private long toNumber(String value) {		return Long.parseLong(value);	}	private String toString(boolean value) {		return value ? "true" : "false";	}	private String toString(long value) {		return String.valueOf(value);	}		private boolean isEmpty(String value) {		return JRemUtils.isEmptyString(value);	}		public boolean getBooleanValue(String propName) {		String value = p.getProperty(propName);				return toBoolean(value);	}	public boolean getBooleanValue(String propName, boolean defValue) {		String value = p.getProperty(propName);		if (isEmpty(value))			return defValue;		return toBoolean(value);	}	public long getNumberValue(String propName) {		String value = p.getProperty(propName);		return toNumber(value);	}	public long getNumberValue(String propName, int defValue) {		String value = p.getProperty(propName);		if (isEmpty(value))			return defValue;		return toNumber(value);	}	public String getStringValue(String propName) {		String value = p.getProperty(propName);		return value;	}	public String getStringValue(String propName, String defValue) {		String value = p.getProperty(propName);		if (isEmpty(value))			return defValue;				return value;	}		public void setBooleanValue(String propName, boolean value) {		p.setProperty(propName, toString(value));			}	public void setNumberValue(String propName, int value) {		p.setProperty(propName, toString(value));			}	public void setStringValue(String propName, String value) {		p.setProperty(propName, value);			}	public void store() {		OutputStream fo = null;				try {					File f = new File(propFilePath);			fo = new FileOutputStream(f);			p.store(fo, propDescription);					} catch (Exception e) {			throw new JRemRuntimeException(e);					} finally {							if (fo != null) {					try {						fo.close();					} catch (IOException e) {						// Ignored					}				}		}	} }

⌨️ 快捷键说明

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