Possible Duplicate:
Java Too Many Open Files
This is not a duplicate, the referred question is different, only the title is same, please read carefully
This is my file write function
public static void WriteLog(String LogLine) {
String filePath = CommonClass.ReadPropertiesFile("LogFilepath");
BufferedWriter out = null;
try {
// Create file
FileWriter fstream = new FileWriter(filePath, true);
out = new BufferedWriter(fstream);
out.write(LogLine + "\r\n");
} catch (Exception e) {//Catch exception if any
System.err.println("Error: " + e.getMessage());
} finally {
//Close the output stream
if (out != null) {
try {
out.write("Closing stream\r\n");
out.close();
} catch (IOException ex) {
System.err.println("Error Closing stream: " + ex.getMessage());
Logger.getLogger(LogWritter.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
i have also seen this question but it doesn't seem to help, if close is a blocking call then it shouldn't give this problem.
but when i call WriteLog function too frequently i.e. in a loop i get this error:
Error: (No such file or directory)
Could not load properties File, Exception: (Too many open files),
Error: (No such file or directory)
Could not load properties File, Exception: (Too many open files),
After some specific number of calls, on every subsequent call i keep on getting this error and no more text is written in the file. Can anybody tell me the reason I am totally confused.
Thanks in advance