Help with Java Program

Status
You're currently viewing only ssmith's posts. Click here to go back to viewing the entire thread.
Not open for further replies.

ssmith

Ars Scholae Palatinae
928
To avoid using a native method, it may be simpler to use Runtime.exec( ) to do a DIR /t:a <dir_name>, then catch and parse the output.
It will probably look a bit like this:

code:<HR>
Code:
String dir = "c:/";<P>Process process = Runtime.exec( "dir /t:a " + dir );
BufferedReader reader = new BufferedReader( new InputStreamReader( process.getInputStream( ) ) );
process.waitFor( );<P>String lineIn = null;
while( null != ( lineIn = reader.readLine( ) ) )
{
    // parse the strings coming in
}<P>

I haven't compiled and run this, but it's there abouts. Certainly quite easily doable. Hope it helped.

edit: wrong way round :eek:

[This message was edited by ssmith on January 09, 2002 at 18:14.]
 
Status
You're currently viewing only ssmith's posts. Click here to go back to viewing the entire thread.
Not open for further replies.