Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

File writing taking long time.

807569Jun 21 2006 — edited Jun 21 2006
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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 19 2006
Added on Jun 21 2006
18 comments
277 views