【问题标题】:Default constructor cannot handle exception type IOException thrown by implicit super constructor. of Fileinputstream默认构造函数无法处理隐式超级构造函数抛出的异常类型 IOException。文件输入流
【发布时间】:2015-07-14 06:05:51
【问题描述】:

我有两个 java 文件:
1) 读取文件数据.java

public class ReadFileData {
protected Properties prop = new Properties();
public ReadFileData() throws IOException {
    FileInputStream  inputStream= new FileInputStream(System.getProperty("user.dir") + "\\Resources\\config.properties");   
    prop.load(inputStream);
}

}

2) 登录.java

ReadFileData data= new ReadFileData();

在创建 readfiledata 对象的这个文件中,我看到了错误。 请帮忙解决这个问题。

【问题讨论】:

标签: selenium-webdriver


【解决方案1】:

无论你在哪里调用这个方法,把它放在 try 和 catch 块中。 try{ReadFileData data= new ReadFileData();}catch(IOException 异常){ System.out.println(exception.getMessage());}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-14
    • 2010-11-14
    相关资源
    最近更新 更多