java - List files in a path which having wildcards using DirectoryScanner -


im using apache directory scanner scan files in path having wildcards.

directoryscanner scanner = new directoryscanner(); scanner.setincludes(new string[]{"*/*.java"}); scanner.setbasedir("c:/temp"); scanner.setcasesensitive(false); scanner.scan(); string[] files = scanner.getincludedfiles(); 

the problem here if use above code display java files inside sub directories of temp , not java files directly in temp folder.

also have notice if use (new string[]{"*.java"}) list java files in temp folder , (new string[]{"**/*.java"}) list java files inside sub directories of sub directory. question here is,

1) standard wild card syntax apply every where? mean **/ means directories , */ means sub directories?

2)how files in temp directory directly , inside sub directoroes (not again inside sub directories use **)

3)now can see when using directoryscanner have base directory , relavanat wildcard syntax. but suppose have wildcards in middle of base directoy too. if how can use directoryscanner?

thank you.

try using:

scanner.setincludes(new string[]{"*/*.java", "*.java"}); 

add every needed wildcard array. there special reason why you're using directoryscanner? using self-written recursive function seems easier.

see http://leepoint.net/notes-java/io/10file/20recursivelist.html


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -