如何读取驻留在webcontent / META-INF文件夹中的txt文件的内容 [英] How do I read contents of txt file residing in webcontent/ META-INF folder

查看:265
本文介绍了如何读取驻留在webcontent / META-INF文件夹中的txt文件的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想读取驻留在项目的webcontent / META-INF文件夹中的文件的内容。 Web INF不在于类路径,这就是问题持续存在的地方。我尝试使用:



String dir = System.getProperty(user.dir);

InputStream in;



in = new FileInputStream(dir +/ src / main / webapp / META-INF / output.txt);



但这里user.dir返回我服务器所在的目录而不是项目所在的位置。如何获取我想要读取内容的txt文件的相对路径。



请帮助。:(

解决方案

Webcontent / META-INF文件夹不在于类路径,这就是问题仍然存在的地方

Hi,

I want to read the contents of a file residing in webcontent/ META-INF folder of my project. Web INF doesnt lie in the classpath and that is where the problem persist. I tried using :

String dir = System.getProperty("user.dir");
InputStream in;

in = new FileInputStream(dir + ""/src/main/webapp/META-INF/output.txt");

but here user.dir is returning me the directory where my server is residing and not where the project is. How do I get the relative path of the txt file I want to read the contents from.

Please help. :(

解决方案

Webcontent/ META-INF folder doesnt lie in the classpath and that is where the problem persists.


这篇关于如何读取驻留在webcontent / META-INF文件夹中的txt文件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆