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.
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.
Joined: Dec 19, 2001
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.