• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Scan files which having wild cards using apache DirectoryScanner

 
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Master Rancher
Posts: 4806
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You save more money with a clothesline than dozens of light bulb purchases. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic