java.io.FileNotFoundException: (Access is denied) java.io.FileNotFoundException: (Access is denied) java java

java.io.FileNotFoundException: (Access is denied)


You cannot open and read a directory, use the isFile() and isDirectory() methods to distinguish between files and folders. You can get the contents of folders using the list() and listFiles() methods (for filenames and Files respectively) you can also specify a filter that selects a subset of files listed.


  1. check the rsp's reply
  2. check that you have permissions to read the file
  3. check whether the file is not locked by other application. It is relevant mostly if you are on windows. for example I think that you can get the exception if you are trying to read the file while it is opened in notepad


Also, in some cases is important to check the target folder permissions. To give write permission for the user might be the solution. That worked for me.