Java 读写properties配置文件
Java 读写Properties配置文件,利用Properties的属性load、setProperty、getProperty。
load(InputStream inStream)方法可以从.properties属性文件对应的文件输入流中,加载属性列表到Properties类对象
getProperty/setProperty这两个方法是分别是获取和设置属性信息
配置文件如下:
如何读取?构造方法、读取配置文件的java程序如下:
import java.util.Properties;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.IOException;
public class propertUtil {
private Properties prop;
private String filePath;
/**
* 构造方法
**/
public propertUtil(String filePath) {
this.filePath = filePath;
this.prop