import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
import java.util.Iterator;
import java.util.Properties;
public class AA {
public static void main(String[] args) {
URL classPath = Thread.currentThread().getContextClassLoader().getResource("");
String path = classPath.getPath();
System.out.println(",," + path);
String proFilePath = classPath.toString();
System.out.println(",," + proFilePath);
String auth = "";
File fileRedis = new File(path + "redisdb.properties");
if (fileRedis.exists()) {
System.out.println("文件存在");
Properties prop = new Properties();
try {
// 读取属性文件a.properties
InputStream in = new FileInputStream(fileRedis);
prop.load(in); // /加载属性列表
Iterator it = prop.stringPropertyNames().iterator();
while (it.hasNext()) {
String key = it.next();
System.out.println(key + ":" + prop.getProperty(key));
}
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}else{
System.out.println("文件不存在");
}
}
}