C
Collin VanDyck
Hi,
This problem just started coming up in our application. It is a publishing
application that writes pages and other items to disk, possibly managing
many different sites at the same time.
The user has the option of publishing all of the sites, which then invokes a
routine that writes all of the pages in all of the sites to disk before
FTP'ing them to the remote server.
The problem I'm seeing is that after a couple of minutes, I get a (Too many
open files) explanation as java.io.FileNotFoundExceptions start cropping up.
In my application, I am using java.io.File in the following manner:
protected java.io.File writeFile(params...) {
java.io.File outputFile = new java.io.File(fileName);
FileOutputStream out = new FileOutputStream(outputFile);
out.write(fileContent.toByteArray());
out.close();
return outputFile;
}
The outputFile that is returned is used later to locate the file by pathName
when sending over FTP, but I get this error without invoking the FTP step.
For some reason, the FileOutputStream.close() method does not seem to be
releasing the file back into the operating system. I verified this by
trying to delete the temporary file created by the above method, and WinXP
told me that it could not, as it was being used by another process.
Anyone have any ideas on why this is happening? I think that the close()
method should do what I want, but apparently it is not. Thanks!
Collin
This problem just started coming up in our application. It is a publishing
application that writes pages and other items to disk, possibly managing
many different sites at the same time.
The user has the option of publishing all of the sites, which then invokes a
routine that writes all of the pages in all of the sites to disk before
FTP'ing them to the remote server.
The problem I'm seeing is that after a couple of minutes, I get a (Too many
open files) explanation as java.io.FileNotFoundExceptions start cropping up.
In my application, I am using java.io.File in the following manner:
protected java.io.File writeFile(params...) {
java.io.File outputFile = new java.io.File(fileName);
FileOutputStream out = new FileOutputStream(outputFile);
out.write(fileContent.toByteArray());
out.close();
return outputFile;
}
The outputFile that is returned is used later to locate the file by pathName
when sending over FTP, but I get this error without invoking the FTP step.
For some reason, the FileOutputStream.close() method does not seem to be
releasing the file back into the operating system. I verified this by
trying to delete the temporary file created by the above method, and WinXP
told me that it could not, as it was being used by another process.
Anyone have any ideas on why this is happening? I think that the close()
method should do what I want, but apparently it is not. Thanks!
Collin