I’ve written an application that runs flawlessly in windows, and throws this error on unix.
Generally, I dont understand why I’m getting this error! I create a single file and .append text to it. After I’ve appended a couple thousand lines I got this error…
Any insight would be appreciated.
Nothing in the javadoc listed this (too many files open) error: https://docs.oracle.com/javase/1.5.0/docs/api/java/io/FileNotFoundException.html.
And this post didn’t help me:
Too many open files: how many are open, what they are, and how many can the JVM open.
Thanks in advance.
Without seeing your code this is guess work, but most likely you are creating a new
FileWriterorFileOutputStreamobject each time you append, but neglect to callclose()on these objects, which eventually causes you to run out of file descriptors (an OS level resource that is independant from memory and thus not adequately handled by garbage collection, requiring manual release).To solve this, either keep a single Stream/Writer around and use it instead of creating a new one each time (this would probably be faster as well), or call
close()each time you’re done appending.