Use the solution provided as a snippet (I don't know Java too) and fill your array retrieving your data from the GTT (or change your design and use the GTT directly)
I think Tom Kyte would just simply point to the existing function instead of providing the solution he did.
I thought the example could be improved upon. I've posted a solution on my blog that doesn't require writing the directory list to a table. It simply returns it as a nested table of files as a SQL datatype. You can find it here: