Get FileNotFoundException when initialising FileInputStream with File object

前端 未结 4 1542
盖世英雄少女心
盖世英雄少女心 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:23

    You might want to make sure that (in order of likely-hood):

    1. The file exists.
    2. The file is not a directory.
    3. You or the Java process have permissions to open the file.
    4. Another process doesn't have a lock on the file (likely, as you would probably receive a standard IOException instead of FileNotFoundException)

提交回复
热议问题