properties配置文件读取方法
package properties;
imp
imp
imp
imp
imp
imp
public class PropertiesTest {
/**
* @param args
*/
public Map<String,String> getAllPath(){
InputStream in;
Map<String,String> map= new HashMap<String,String>();
try {
in = new BufferedInputStream(new FileInputStream("d:\\test.properties"));
Properties p = new Properties();
p.load(in);
String path1 = p.getProperty("path1");
String path2 = p.getProperty("path2");
String path3 = p.getProperty("path3");
System.out.println(path1);
System.out.println(path2);
System.out.println(path3);
map.put("path1", path1);
map.put("path2", path2);
map.put("path3", path3);
return map;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return map;
}
public static void main(String[] args) {
new PropertiesTest().getAllPath();
}
}