Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

How to test a text file is newly created?

Thread view: 
www - 27 Sep 2007 19:53 GMT
Hi,

My program first generate a text file, then read it and process it. The
problem of my current program is that, if running failed, that text file
generated last run will be read and processed.

I hope to check a check to see if the text file is newly generated. It
it is not, that means it is generated by previous run and current run
has failed. The program then stop and will not proceed to read that file.

Could you show me how to do this? Thank you very much.
rossum - 27 Sep 2007 22:52 GMT
>Hi,
>
[quoted text clipped - 7 lines]
>
>Could you show me how to do this? Thank you very much.
Create a file called myfile-new.txt.
Read it and process it.
Rename the file you have just read to myfile-old.txt

If the new file and the old file have different names then the program
will not pick up the old file when it looks for the new one.

rossum
GArlington - 28 Sep 2007 10:09 GMT
> Hi,
>
[quoted text clipped - 7 lines]
>
> Could you show me how to do this? Thank you very much.

How about simple process the file -> delete or archive it? Then after
successful processing run there will be NO file to process, the new
file will ONLY appear AFTER successful generation run.
Is that too trivial?
www - 28 Sep 2007 13:15 GMT
> How about simple process the file -> delete or archive it? Then after
> successful processing run there will be NO file to process, the new
> file will ONLY appear AFTER successful generation run.
> Is that too trivial?

I cannot delete that file, because the file is one of the products I
need. What do you mean "archive it"? One reply suggested:

the program generates myfile_new.txt
the program read and process it
in the end, the program rename myfile_new.txt to myfile_old.txt

That is a reasonable way to achieve my purpose.

Another way suggested by another reply is:
I should set up my program in such a way: if the program fails to
generate that text file, through an exception, then the program will not
proceed to read the text file.

Thank you all for your replies. I greatly appreciate it.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.