tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Tools and Libs > Ostermiller Utilities > How to get dir command output

How to get dir command output 

Ostermiller Java Utilities contain various components such as CSV parsing, Base64 Encoding, MD5 digest, String and Exec Helper classes. This requires the library ostermillerutils-1.08.01.jar to be in classpath. The following example shows getting DIR command output using ExecHelper.execUsingShell() API.

File Name  :  
com/bethecoder/tutorials/ostermillerutils/ExecShellHelperTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.ostermillerutils;

import java.io.IOException;

import com.Ostermiller.util.ExecHelper;

public class ExecShellHelperTest {

  /**
   @param args
   @throws IOException 
   */
  public static void main(String[] argsthrows IOException {
    ExecHelper execHelper = ExecHelper.execUsingShell("dir C:\\Test");
    System.out.println("Process Status : " + execHelper.getStatus());
    System.out.println("OUTPUT : \n" + execHelper.getOutput());
  }

}
   

It gives the following output,
Process Status : 0
OUTPUT : 
 Volume in drive C is EPC_XP
 Volume Serial Number is 60EC-D4D4

 Directory of C:\Test

12/27/2011  01:13 PM    <DIR>          .
12/27/2011  01:13 PM    <DIR>          ..
11/23/2011  03:57 PM                38 abc.txt
11/23/2011  04:02 PM                27 abcd.txt
10/28/2011  11:18 PM            16,444 btc-ascii-table-1.0.jar
10/30/2011  02:00 AM                70 rule_engine_names.txt
11/23/2011  03:51 PM                89 rule_engine_names2.txt
11/23/2011  03:41 PM             5,804 Test.java
               6 File(s)         22,472 bytes
               2 Dir(s)  29,047,209,984 bytes free



                    Print

   



Books Recommendation

 
 
bl  br