Hello all,
I'm using a thirdparty class in my J2EE application which writes encrypted file onto the file system. Its observed that its taking a long time when many users access the system. Tracing I found that its getting delayed in writing the file onto the hard drive. I investigated further that the third party class is using following code to write to file the byte data. I'm suspecting a delay in this block. I wish if the forum buddies throw some light on this:
private static synchronized void
writeFile(String filename, byte[] data)
throws IOException
{
//----------------------------------------------------------------------
// Delete the output file.
File outputFile = new File(filename);
outputFile.delete();
//----------------------------------------------------------------------
// Write the new file.
FileOutputStream out = new FileOutputStream(filename);
out.write(data);
out.close();
}
Its affecting the system users since its a web application where this class is called and its giving a time delay of something like 2-3 minutes for each user. Any feedback is highly appreciated. Kindly suggest the recovery from this.