Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to search for a certain extension within a folder

 
Maha Hassan
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All
I want to search for a certain extention inside the folder
ie *.txt
how can i do this
thanks for help
Maha Aburahma
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this example from the Java Almanac.
 
Megs Maquito
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in DOS:

dir *.txt

in Linux:

ls *.txt
 
Maha Hassan
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Megs Maquito:
in DOS:

dir *.txt

in Linux:

ls *.txt



can i write
File dir = new File ("path");
String [] fileslist = dir.list("ls *.txt");
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, Megs' post tells how to do this from the command line, not from Java. If you look at the API for File, you will find there's no way to use list() with a String argument. (The fact that the code does not compile would be another clue.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic