根据路径读取文件 (struts2/se)

来源:互联网 发布:python 表格控件 编辑:程序博客网 时间:2024/06/07 18:15

// 读取se项目的文件

plan A:

InputStream in = GroupController.class.getClassLoader().getResourceAsStream("config/jdbc.properties");Properties properties = new Properties();try {properties.load(in);} catch (IOException e1) {e1.printStackTrace();}String key = properties.getProperty("rongcd.appkey");String secret = properties.getProperty("rongcd.appsecret");


plan B:

Scanner in = new Scanner(GetTxtValue.class.getClassLoader().getResourceAsStream(filePath),"utf-8");  // filePath文件夹的位置



// 读取ee项目的文件

plan A:(struts2)

String fl = ServletActionContext.getServletContext().getRealPath(filePath); // filePath文件夹的位置
0 0