Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Files and synchronization

 
raj eshwar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
raj eshwar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code is very well formatted, so the poster should get extra points for that. Usually there isn't any indentation at all.
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic