• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving specific file names under given path

 
yekkala krishna
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to retrieve specific file names under given path.I am able to retrieve all the file names given in the specific path in the below code.now i need to retrieve only specific files like if pass html as argument i need to retrieve only html.


regards,
Rama Krishna Y>
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
File#listFiles() is an overloaded method and one version can accept a filter as an argument. Check the Javadoc for details.
 
fioana elegant
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you are getting output like

E:\loginexample\abc.txt
E:\loginexample\abcd.txt
E:\loginexample\abcef.txt

then you can extract filename by substring function
take starting index 0 to lastIndexOf(\)

or

you can use

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic