java读取配置文件
package com.hikvision.readproperties;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
public class readproperties {
public static void main(String[] args) throws IOException {
Properties pps = new Properties();
pps.load(new FileInputStream(args[0]));
Enumeration names = pps.propertyNames();
while (names.hasMoreElements()) {
String strKey = (String) names.nextElement();
String strValue = pps.getProperty(strKey);
System.out.println(strKey + "=" + strValue);
}
}
}
使用带主类的打包方式
https://blog.csdn.net/godlovebinlee/article/details/81073101
直接使用java运行jar程序
D:\a>java -jar a.jar D:\a\a.properties
root=D:/a.txt