how to select *.txt using java,not by FileChooser
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Khaja_Hussain
Posted On:   Sunday, February 11, 2007 01:10 PM

selectin file using listFiles(File Filter)

Re: how to select *.txt using java,not by FileChooser

Posted By:   Axel_Richter  
Posted On:   Sunday, February 11, 2007 02:27 PM

Hi



you may use File.list(FilenameFilter filter) or File.listFiles(FilenameFilter filter) like in this example http://www.exampledepot.com/egs/java.io/GetFiles.html.

File dir = new File("someDir");
FilenameFilter filter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".txt");
}
};
String[] children = dir.list(filter);
for(int i=0; i System.out.println(children[i]);
}

Greetings



Axel
About | Sitemap | Contact