java.io.FileNotFoundException, open failed: ENOENT

前端 未结 4 1081
时光取名叫无心
时光取名叫无心 2020-12-21 16:31

For some reason I am getting a fileNotFoundException for both the times I read. Something worth noting is that the Toast prints \"File exists!\". I used the

4条回答
  •  温柔的废话
    2020-12-21 17:01

    You have already created a File instance with File file = getActivity().getFileStreamPath(filename); which is the instance that you are checking with the file.exists() method. Then you are trying to read another thing with the FileInputStream. You should try FileInputStream fileInputStream = new FileInputStream(file);. With that you are creating your stream with the file that you already checked.

提交回复
热议问题