Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java.io.IOException too many open files  RSS feed

 
Jignesh Gohel
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one class which is creating new FileOutputStream in loop.It is creating 35 files correctly and then after upto 65 files it creates the file but throwing exception JAVA.IO.IOECEPTION :"Cannot create a file when that file already exists" .I have the structure of Class upto 4 classes then after it is create the file in loop.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've listed two exception messages. Too many files open is usually a case of forgetting to close them. Make sure you close all the files you open, perhaps in a finally block, and see if that helps.

Unable to create a file that already exists I don't know about. Can you copy in the exception from the console?
 
Jignesh Gohel
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply i have treind that finally things But it doesn't work I m getting following error
java.io.IOException: Cannot create a file when that file already exists
thanks
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you are getting an IOException, but with which of those error messages?

a) too many open files
b) "Cannot create a file when that file already exists"

Can you perhaps posta small piece of the code too?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!