The decision to "open to a new window" or "download as a file" is a decision for the Browser, not the HTML code (ie not an APEX problem)
Code comments for the code in the blog:
- Listing a directory can be done with EXTERNAL TABLE and a PRE-PROCESSOR. ( Preprocessing: Preprocess External Tables )
- Loading a file into a blob can be done with DBMS_LOB.loadBLOBFromFile();
- The only reason why you'd want to use Java is for descending directories.
- As noted in the blog, the poster did not close the HTTP header. You should fix this.
- I believe the MIME Type should be 'text/text', not 'text/plain
There are many examples of how to send a BLOB as a "download". Remember, it is up to the Browser to decide "download" or "display".
Hope this helps,