Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Scan files which having wild cards using apache DirectoryScanner  RSS feed

 
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Im using apache directory scanner to scan files in a path having wildcards.


The problem here is if i use the above code it will only display java files inside sub directories of Temp and not java files which are directly in Temp folder.

Also I have notice if i use (new String[]{"*.java"}) then it will list all the java files in Temp folder and (new String[]{"**/*.java"}) will list all the java files even inside sub directories of sub directory. So my questions here are,

1) Is this the standard wild card syntax that apply for every where? i mean **/ means all directories and */ means only sub directories?

2)How to get files which are in Temp directory directly and inside sub directoroes only (not again inside those sub directories like we use **)

3)Now we can see when using DirectoryScanner we have base directory and then the relavanat wildcard syntax. But suppose we have wildcards in middle of the base directoy too. If so how can we use the DirectoryScanner?

Thank You.
 
Ranch Hand
Posts: 3091
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not really familiar with Apache Directory Scanner, but here are my answers.

Harshana Dias wrote:1) Is this the standard wild card syntax that apply for every where? i mean **/ means all directories and */ means only sub directories?


It certainly isn't standard for everything. But it seems to be reasonably common for modern open-source software, when talking about files.

Harshana Dias wrote:2)How to get files which are in Temp directory directly and inside sub directoroes only (not again inside those sub directories like we use **)


I would try

The reason they use an array there is that they want to allow multiple entries (and they're still in the pre-JDK 5 dark ages). I would assume that if you put multiple entries into the array, they will be used.

Harshana Dias wrote:3)Now we can see when using DirectoryScanner we have base directory and then the relavanat wildcard syntax. But suppose we have wildcards in middle of the base directoy too. If so how can we use the DirectoryScanner?


I would use the DirectoryScanner twice, or more. The first time, set the base directory to something like "C:/", and search for directories that match the pattern with a wildcard. Then use DirectoryScanner once more for each matching directory you found, setting that directory as base directory.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!