2011-10-29 59 views
1

我正在处理Web应用程序,并且我在包com.xx.yy中创建了一个属性文件。我需要从作者包com.aa.bb中的类中读取此文件。我在使用FileInputStream读取属性文件时遇到问题

我有如下因素代码:

try { 
    FileInputStream fileInputStream = new FileInputStream("com/xx/yy/myfile.properties"); 
    internationalizationFile = new Properties(); 
    internationalizationFile.load(fileInputStream); 
    fileInputStream.close(); 
} catch (Exception e) { 
    e.printStackTrace(); 
} 

,但它不工作!

+1

你会得到什么?例外? –

回答

2

您是否尝试通过类加载器加载资源?像:

InputStream in = this.getClass().getClassLoader.getResourceAsStream("com/xx/yy/myfile.properties"); 
相关问题