Get FileNotFoundException when initialising FileInputStream with File object

前端 未结 4 1550
盖世英雄少女心
盖世英雄少女心 2020-12-11 18:04

I am trying to initialise a FileInputStream object using a File object. I am getting a FileNotFound error on the line

fis = new FileInputStream(file);
         


        
4条回答
  •  不知归路
    2020-12-11 18:15

    I think you are executing the statement from eclipse or any java IDE and target file is also present in IDE workspace. You are getting the error as Eclipse cant read the target file in the same workspace. You can run your code from command prompt. It should not through any exception.

提交回复
热议问题