How to test a text file is newly created? - Java

This is a discussion on How to test a text file is newly created? - Java ; 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 ...

+ Reply to Thread
Results 1 to 4 of 4

How to test a text file is newly created?

  1. Default How to test a text file is newly created?

    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.

  2. Default Re: How to test a text file is newly created?

    On Thu, 27 Sep 2007 14:53:43 -0400, www <www@nospam.com> wrote:

    >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.

    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


  3. Default Re: How to test a text file is newly created?

    On 27 Sep, 19:53, www <w...@nospam.com> wrote:
    > 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.


    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?


  4. Default Re: How to test a text file is newly created?

    GArlington wrote:

    >
    > 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.

+ Reply to Thread

Similar Threads

  1. How to test a text file is newly created?
    By Application Development in forum Java
    Replies: 4
    Last Post: 09-27-2007, 10:47 PM
  2. How to export data read from Excel file to a newly created DBF
    By Application Development in forum ADO DAO RDO RDS
    Replies: 0
    Last Post: 04-14-2007, 11:26 PM
  3. Cannot see neither access newly created mailboxes
    By Application Development in forum Microsoft Exchange
    Replies: 7
    Last Post: 03-28-2007, 02:51 AM
  4. How to insert an image file from the databasein a newly created page?
    By Application Development in forum Adobe Indesign
    Replies: 1
    Last Post: 12-12-2006, 03:54 AM
  5. Replies: 0
    Last Post: 12-01-2006, 04:52 AM