Directory Listing in Rhino

Posted by: Terry Ryan on March 2, 2012

This is pretty simple, but I couldn't find it via searching, so I thought a little write up was in order.

I'm fooling around with Rhino, which is a JavaScript engine written in Java.  It allows you to do a lot, but in my case I am using it to write JavaScript helper scripts for ANT.  I'm working on a project for which I want to only write in HMTL/JavaScript/CSS.  I have to write some ANT scripts, but anything that I can't accomplish with ANT, which means I need a scripting language to do, I decided to do in JavaScript.  Rhino allows me to accomplish that.

I'll post more about what I'm trying to do when I release more about the project.  For this step, I needed to get a list of all of my files in my project so I could manipulate them in JavaScript.  I looked for a directoryList function, but only found this post on Directory Traversal. So I whipped up my own script for DirectoryList in JavaScript using Java on Rhino:

Terry Ryan

About Terry Ryan

Terry Ryan is a Worldwide Developer Evangelist for Adobe. The job basically entails helping developers using Adobe technologies to be successful. His focus is on web and mobile technologies including expertise in both Flash and HTML. Previous to that, he spent a decade working in various technical roles at the Wharton School at the University of Pennsylvania.

Terry is also the author of Driving Technical Change, a Pragmatic Bookshelf title. It's about convincing reluctant co-workers to adopt new tools and ideas.

He blogs at http://terrenceryan.com/blog and is tpryan on Twitter.