简体   繁体   English

使用NetBeans在JSP Project中放置文本文件的位置

[英]Where to put a text file in JSP Project with NetBeans

I'm accessing a method of class(which is not servlet) from servlet. 我正在从servlet访问类的方法(不是servlet)。

I'm reading a properties file inside this m1. 我正在读取此M1中的属性文件。

Properties props=null
InputStream input = new FileInputStream("Interface.properties");
props.load(input);

But it is showing IOException. 但是它显示了IOException。 I don't want to give relative path. 我不想给出相对路径。 Where should i put this file to run it smoothly. 我应该把这个文件放在哪里才能平稳运行。

Right now I've put the file @ 现在我把文件@

/home/sys6002/NetBeansProjects/MyProject/Interface.properties /home/sys6002/NetBeansProjects/MyProject/Interface.properties

You can put the file in your classpath and you can load it like this: 您可以将文件放在类路径中,并可以像这样加载它:

Properties properties = new Properties();
properties.load(this.getClass().getResourceAsStream("Interface.properties"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM