• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

FileNotFoundException((Permission denied)

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I'm a lumberjack and I'm okay, I sleep all night and work all day. Lumberjack ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic