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");

你可能感兴趣的:(java,Web)