Open a file that I dont know it exactly name: patterns?

Hi,

I must open a file but I dont know the exactly name, only it finish letters:

For example, I have the next files:

21_4_2007_SLOT.txt

21_4_2007_HALF.txt

21_4_2007_ALL.txt

And I must open only the file that finishes with _SLOT.txt

The first part of the file name changes depending the date (for example) so I cant use that.

For example, in this code:

byte[] data =null;

try{

in =new FileInputStream(fileName);

data =newbyte[in.available()];

in.read(data);

}catch (Exception e){

e.printStackTrace();

}

So I would like to change fileName for a pattern like *_SLOT.txt.

Can I do this using Java?

[1050 byte] By [JAX82a] at [2007-11-27 2:38:06]
# 1
You could use the list() or listFiles() methods of File to get the names of all the files in that directory, then parse them to find which one you want to use. (String.endsWith())
hunter9000a at 2007-7-12 2:58:56 > top of Java-index,Java Essentials,Java Programming...