Reading files with changing names


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Reading files with changing names

  1. #1
    Join Date
    Apr 2007
    Posts
    5

    Reading files with changing names

    every few hours my AS400 generates a text fille with the following naming convention:

    "IR + 6 digit number which incriments by one each time a file is generated + _ + The start date and time for the file +_to_ + end date and time for the file + .txt". For example IR000002_20070528141515_to_20070528170003.txt is the name of the second file generated which started at 14:15:15 on 28/05/2007 and ended at 17:00:03 on 28/05/2007.

    I want my Java program to read each file generated. I know how to do this when the file generaed is the same each time but havnt a clue now that each file has a different name. Can anybody help?

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    I interpret your question as containing the supposition that you are processing your files programmatically, rather than through user action on a JFileChooser.

    You can use the list() method of File with a class which implements the FileFilter interface whose accept() method filters for the file names which meet your criterion, adding each filtered file name into a vector(or Set?) of strings. Then process your files by iterating through the vector of file names. An appropriate filter might be s.startsWith("IR").

  3. #3
    Join Date
    Apr 2007
    Posts
    5
    Yes. I intend for my program to run automatically. Each time it does it will find the latest text file that has been generated and convert it to XML.

Similar Threads

  1. Reading Text/CSV files
    By Neville in forum VB Classic
    Replies: 1
    Last Post: 05-24-2001, 11:51 AM
  2. Changing field names in a table through VBA
    By Jeff in forum VB Classic
    Replies: 7
    Last Post: 03-30-2001, 08:15 PM
  3. Reading operating system files
    By Venky in forum XML
    Replies: 4
    Last Post: 09-27-2000, 05:09 PM
  4. Reading a test files using ADO
    By Ted Young in forum VB Classic
    Replies: 1
    Last Post: 08-15-2000, 10:17 AM
  5. Reading ASCII data files
    By Bill in forum VB Classic
    Replies: 0
    Last Post: 07-31-2000, 01:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center