• Post Reply Bookmark Topic Watch Topic
  • New Topic

FileNotFoundException((Permission denied)

 
Daksh Pppp
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Reading file into inputStream is sporadically throwing FileNotFoundException((Permission denied).I am using the java.io.inputStream to read the file to the Stream
InputStream inputStream = new FileInputStream(file);

The code is running in multithreaded enviroment,where at any time only a single thread had access to a file.But at times specifically when the more number of files are been processed at the same time the above piece of code is throwing FileNotFoundException(Permission denied).

The File is not a directory,it does exists.And the user has permissions to read the file.When I process the same file again without any change in the code it works through.

Can not enough JVM space results in a FileNotfound Exception?

Please advice.
 
Greg Charles
Sheriff
Posts: 3010
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never seen a lack of heap space cause a "Permission Denied" error. Are you running on Windows. Windows tends to be ... what that word? Oh, yeah, psycho. Window tends to be psycho about file locks. Mainly that's for write access to a file, but sometimes for read access too. Are you being careful to close FileInputStreams (and FileOutputStreams) to the file? You should always open resources in a try block and close them in a finally block, to make sure everything is cleaned up even when there's an exception. Keeping too many files open will run you into problems on any OS.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!