File searching

Dear all,Can you help me ? Let's say in a folder contains :- A.doc- B.txt- C.datHow can I get filename, based on the extension (e.g. "doc" or "dat") ?Thank you
[216 byte] By [bronze-starDukes] at [2007-11-26 12:15:27]
«« how get
»» Need help
# 1
I havent worked with RE in java but if i was programming in lex and yacc i would have read each filename from the directory and compared it with [_a-zA-Z]+[0-9_a-zA-Z]*\."doc" and if it is valid its a .doc file
silverstar at 2007-7-7 14:19:21 > top of Java-index,Archived Forums,Socket Programming...
# 2
If java uses RE the same way you can use it.Actually RE's are used the same way everywhere but wouldnt want to misguide you by saying its the same way in java too.Check out the tutorials
silverstar at 2007-7-7 14:19:21 > top of Java-index,Archived Forums,Socket Programming...
# 3
What do you mean by get the filename based upon the extension?Are you trying to filter the listing that you would receive from - say - the JFileChooser?
bronzestar at 2007-7-7 14:19:21 > top of Java-index,Archived Forums,Socket Programming...
# 4

> What do you mean by get the filename based upon the

> extension?

>

> Are you trying to filter the listing that you would

> receive from - say - the JFileChooser?

perhaps you can understand through this illustration

for(all Files)

{

if(extension.equals(".doc");

System.out.println(Filename);

}

Thank you

bronzestar at 2007-7-7 14:19:21 > top of Java-index,Archived Forums,Socket Programming...
# 5
if(yourfile.getName().endsWith(".doc")){
platinumsta at 2007-7-7 14:19:21 > top of Java-index,Archived Forums,Socket Programming...
# 6
This might help.The answer according to me lies in RE because i have used it to achieve similar tasks,Read this http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html
silverstar at 2007-7-7 14:19:21 > top of Java-index,Archived Forums,Socket Programming...