{"id":150,"date":"2006-08-09T23:21:48","date_gmt":"2006-08-10T04:21:48","guid":{"rendered":"http:\/\/www.juixe.com\/techknow\/index.php\/2006\/08\/09\/jakarta-commons-io\/"},"modified":"2006-08-09T23:21:48","modified_gmt":"2006-08-10T04:21:48","slug":"jakarta-commons-io","status":"publish","type":"post","link":"http:\/\/juixe.com\/techknow\/index.php\/2006\/08\/09\/jakarta-commons-io\/","title":{"rendered":"Jakarta Commons IO"},"content":{"rendered":"<p>I have written plenty of one-off no-brainer recursive Java methods that search through a directory hierarchy searching for a type of files.  Such methods are good exercise problems for rookie Java programmers.  But since I am a Java programmer I bearly exercise, so I tend not to write that type of method anymore.  I let <b>Jakarta Commons IO<\/b> do the recusive file seach for me.  Using the FileUtils, SuffixFileFilter, and TrueFileFilter from the Commons IO library I could recursively search a directory hierarchy for all groovy files with the following bit of code:<\/p>\n<pre>\nSuffixFileFilter sff = new SuffixFileFilter(\".groovy\");\n\/\/ listFiles(File directory, IOFileFilter fileFilter, IOFileFilter  dirFilter)\nCollection cl = FileUtils.listFiles(f, sff, TrueFileFilter.INSTANCE);\n<\/pre>\n<p>Other useful FileFilter classes available in the Commons IO library include PrefixFileFilter, NamedFileFilter, DirectoryFileFilter, and FalseFilterFilter.<\/p>\n<p>Technorati Tags: <a href=\"http:\/\/technorati.com\/tag\/java\" rel=\"tag\">java<\/a>, <a href=\"http:\/\/technorati.com\/tag\/jakarta\" rel=\"tag\"> jakarta<\/a>, <a href=\"http:\/\/technorati.com\/tag\/commons+io\" rel=\"tag\"> commons io<\/a>, <a href=\"http:\/\/technorati.com\/tag\/recursive\" rel=\"tag\"> recursive<\/a>, <a href=\"http:\/\/technorati.com\/tag\/groovy\" rel=\"tag\"> groovy<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have written plenty of one-off no-brainer recursive Java methods that search through a directory hierarchy searching for a type of files. Such methods are good exercise problems for rookie Java programmers. But since I am a Java programmer I bearly exercise, so I tend not to write that type of method anymore. I let [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[15,3],"tags":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p902K-2q","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/150"}],"collection":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/comments?post=150"}],"version-history":[{"count":0,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/150\/revisions"}],"wp:attachment":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/media?parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/categories?post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/tags?post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}