Spy*_*iam 1 java netbeans nullpointerexception fileinputstream
我有一个bean需要从属性文件中获取一些参数但我找不到它(java.lang.NullPointerException)才能打开它.我的bean在extra.beans包中,而属性文件在extra.dao包中.我想做
file = new FileInputStream("database.properties");
prop.load(file);
Run Code Online (Sandbox Code Playgroud)
我已尝试任何可能的组合路径,但我找不到它.我正在使用Netbeans 7.4.我该怎么打开它?
您可以使用Resource Bundle.
ResourceBundle resBundle = ResourceBundle.getBundle("PropertyFileName"); // without extention
String name= resBundle.getString("Required Attribute"); // example username
Run Code Online (Sandbox Code Playgroud)