public class SupplierCalculatorApplet extends JApplet{ ... public void init(){ loadProperties(); ... } ... private void loadProperties() { language = "en-us";//getParameter("Language"); prop = new Properties(); try { URL urlToProps = this.getClass().getResource("config/" + language + ".properties"); prop.load(urlToProps.openStream());//Exception Caught Here } catch (IOException e) { } }
在上面指出的行中发现异常。无论语言是否是有效的属性文件,我都会在同一行上捕获相同的异常。
改成:
prop.load(this.getClass().getResourceAsStream("/config/" + language + ".properties"));