Java web 项目读取src或者tomcat下class目录下的xml文件或者properties文件
2014-05-08 15:04
751 查看
//生成一个文件对象: File file = new File(getClass().getClassLoader().getResource("test.xml").getPath()); //直接得到一个输入流: InputStream in = getClass().getClassLoader().getResourceAsStream("test.xml"); //在当前线程获取--这个方法不大稳定 //String path = Thread.currentThread().getContextClassLoader().getResource("").getPath()+"/test.xml"; //推荐使用此方法 String path = getClass().getClassLoader().getResource("test.xml").getPath();
相关文章推荐
- Java web 项目读取src或者tomcat下class文件夹下的xml文件或者properties文件
- 读取web项目properties文件路径 解决tomcat服务器找不到properties路径问题
- Java在Web项目中读取properties文件
- java web项目读取properties文件
- Eclipse 使用maven管理发布web项目在tomcat里面只有java文件没有class文件
- javaweb读取任意目录的下的properties配置文件(解决普通java类读web-inf下任意目录)
- 在tomcat运行找不到xml,class ,项目中的java文件没有在WEB-INF\classes中生成class文件
- Java web项目中读取properties,xml文件
- java项目中读取src目录下的文件
- web项目读写src目录下的.properties文件
- java web项目读取properties文件方法
- Web项目Java读取Properties文件出现“The system cannot find the file specified”解决
- eclipse环境下部署到Tomcat中的项目目录下缺失class文件或者不更新
- 读取web项目web-inf目录下的jdbc.properties文件
- Java读取WEB-INF目录下的properties配置文件
- JavaWeb项目中WEB-INF目录下class文件自动生成以及显示
- Java读取WEB-INF目录下的properties配置文件
- tomcat发布后,没有class文件,只有项目目录和properties,xml之类的文件解决办法
- Java读取src目录下的properties配置文件
- Java读取WEB-INF目录下的properties配置文件