zhangym 发表于 2013-2-3 13:35:23

java读取属性文件

ServletContext context =ServletActionContext.getServletContext();

String strServerPath=context.getRealPath("");

String path = context.getContextPath();

File file = new File(strServerPath+"/WEB-INF/classes/config/mail.properties");  

FileInputStream input = new FileInputStream(file);  

Properties p =  new Properties();  

p.load(input);  

String from=p.getProperty("mail.from");

String Target=p.getProperty("mail.text");  

String text=new String(Target.getBytes("ISO-8859-1"),"GBK");
页: [1]
查看完整版本: java读取属性文件