wood burning stoves 2.0*
The moose likes JSP and the fly likes Simple Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Simple "dir" command in DOS file structer JSP server via JSP page" Watch "Simple "dir" command in DOS file structer JSP server via JSP page" New topic
Author

Simple "dir" command in DOS file structer JSP server via JSP page

Jeff Grant
Ranch Hand

Joined: Dec 19, 2001
Posts: 169
I've done some searches here and on google for information about this.
It seems, in general, that there is no way to return a "dir" query back to where it was called. There is much information on program execution, but whenever the "dir" command is mentioned, the thread stops with no solutions.
......
On a side note, the reason why I want to get the results of "dir" is so that I can design my own JSP displayed file system for a project I have been working on. I figure that with the results, I can parse out directories and file names. If there is an easier way to do this, I am, of course, definitely open to them. But for now this is the most straight foreward way I could think of.
Either way, I'd like to know how to get the result of "dir" back.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Actually it will be much easier to use java.io.File to get the contents of a directory. With File.list() you can use a FileNameFilter for example.
Bill
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15959
    
  19

As William mentioned, the java.io.File class provides much tidier ways of running through a filesystem - plus the results aren't dependent on the OS and any convironmental command options.
Just for the sake of saying so, I think that you'd have to use java.lang.System.setOut() to redirect the VM's standard output stream, then do a Runtime.exec to execute the "dir" command. The problem is, this would possibly collide with other threads in the same VM also writing to stdout.
But it's not worth the trouble of researching in-depth just to get a directory listing.


Customer surveys are for companies who didn't pay proper attention to begin with.
Jeff Grant
Ranch Hand

Joined: Dec 19, 2001
Posts: 169
Great, thanks for the suggestion to use java.io.File.
I have toyed with it a little now and have the directory/file structure established.
Thanks for the help.
 
Don't get me started about those stupid light bulbs.
 
subject: Simple "dir" command in DOS file structer JSP server via JSP page
 
Similar Threads
getting output from DOS into GUI
Retrieving map reduce results
question of "include" in JSP spec 2.0
Get Host appbase Path of a JSP in Tomcat
Runtime.exec problems