How can I check how many files with specific names exist in a directory?

J

John

I am writing a generic database with many independent data files named
data1.dat, data2.dat,...

For a user to resume entering new data file, the application must check how
many already exist when it start.

Is there anything like file.exist() to can perform such action?

Do I have to write loop to track all files or maybe there is some similar
function already embedded in Java?

John
 
J

Joshua Cranmer

John said:
I am writing a generic database with many independent data files named
data1.dat, data2.dat,...

For a user to resume entering new data file, the application must check how
many already exist when it start.

Is there anything like file.exist() to can perform such action?

Do I have to write loop to track all files or maybe there is some similar
function already embedded in Java?

John

What you want to look at the list() or listFiles() functions of the
java.io.File class. You may also want to investigate the FileFilter or
FilenameFilter class as well.


AFAIK, there is no function in Java that will automatically manage a
data_n.dat system of files unless they are being used for logging.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top