如何读取驻留在webcontent / META-INF文件夹中的txt文件的内容 [英] How do I read contents of txt file residing in webcontent/ META-INF folder
问题描述
我想读取驻留在项目的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屋!