获得properties文件的路径,读取properties文件的参数

来源:互联网 发布:mac激活时间相差20天 编辑:程序博客网 时间:2024/05/16 00:51


import java.util.*;

import java.io.*;

public class test{
  private String findPath()
    {
        String path = getClass().getClassLoader().getResource("").getPath();
        int pathLength = path.length();
        path = path.substring(1, pathLength);
        path = path + "my.properties";
        return path;
       
    }


 public static void main(String args[]) throws Exception{
 
  Properties pr = new Properties();
  test t = new test();
 
  String path=t.findPath();
  System.out.println("aaaaa"+path);
  FileInputStream fis = new FileInputStream("my.properties");
  pr.load(fis);
  pr.list(System.out);

}
}
  

原创粉丝点击