2008/06/11

Apache Commons

Java is an obtuse beast, written by obtuse beasts.

I will be detailing efforts to use the apache commons io framework (DirectoryWalker in particular) in this post.

Apache Commons consists of several helpful extensions to Java in various areas, IO in particular being the one I'm interested, though Math and XML processing code exists for anyone to take advantage of.

Problems that I'm currently working through:
  • DirectoryWalker seems to include mechanics for depth limitations, but the default means of shuffling the File objects returned seems to be an Array, the search process itself seems to dive into the filesystem in a chaotic and unseemly way, that does not lend itself to being easily limited to a certain depth.
  • Java in general, is somewhat defiant of concrete scrutiny to non domain level experts. So, if one isn't already an expert Java programmer, one cannot take at face value the indications of the documentation for modules involved.
At the moment, I'm determining if indeed I can throw a DirectoryWalker.CancelException and how much more code I'll have to write to do something that is quite simple in a shell script (gnu find, and the parameters --maxdepth --mindepth) in order to mitigate the lack of an ability to constrain a directory walk to an exact distance from a starting point.

From the documentation:
This class operates with a FileFilter and maximum depth to limit the files and direcories visited. Commons IO supplies many common filter implementations in the filefilter package.

References:
(http://commons.apache.org/io/api-release/org/apache/commons/io/DirectoryWalker.html)

No comments: