aspose file tools*
The moose likes Threads and Synchronization and the fly likes Files and synchronization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Files and synchronization" Watch "Files and synchronization" New topic
Author

Files and synchronization

raj eshwar
Greenhorn

Joined: Feb 14, 2005
Posts: 5
Hi, I have a text file used for tracing purposes. I have to do a validation before each line is written to the file...like it has to compare the date the file is created and current file.Whenever the file is created , a time stamp is written as the first line. If the file is 2 days old It has to be renamed as a backup file and a new file has to be created for logging. Below is my code. I do not know which part of the synchronization is wrong. A new file is created, but it is not renamed. Can some one please help me.




Thanks
Raj.

[ March 02, 2005: Message edited by: raj eshwar ]
[ March 02, 2005: Message edited by: raj eshwar ]
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
I think you're unlikely to find someone who'll trawl that much code looking for your error. We're busy people, you know!

I can see one thing that doesn't look good. All MyBuffer's data, including objLock, is static, yet it is assigned in the instance constructor. Unless MyBuffer is a singleton class (in which case it should have private, not public, constructor), that's broken.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
raj eshwar
Greenhorn

Joined: Feb 14, 2005
Posts: 5
Sorry Peter.. I know that is a very lengthy code to post in a forum.. But I've been stuck with it for a while...Thats why.. being desperate...

Thanks for your reply...I am still trying to fix this

Thanks
Raj
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

The code is very well formatted, so the poster should get extra points for that. Usually there isn't any indentation at all.


Please ignore post, I have no idea what I am talking about.
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

> A new file is created, but it is not renamed.

So the new file has the same name? In that case does the original file gets overwritten? I am confused.
raj eshwar
Greenhorn

Joined: Feb 14, 2005
Posts: 5
William,
I meant to say the old file is not renamed. but a new file(for ex say mylog.txt) is created(or overwritten , I am not sure what is happening there) for further logging. This is what I have to do,
1. Close all the streams to the mylog.txt file
2. Rename mylog.txt to mylog.bkp
3. Delete mylog.txt
4. Create mylog.txt for further logging.

Thanks
Raj
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Files and synchronization
 
Similar Threads
Date (GregorianCalender)
Creating Exel File, streamming
Output directory listing to an XML
redirect System.out
streaming excel files on ServletOutputStream