tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Java Scripting > BeanShell > Dir Command

Dir Command 

BeanShell is a small, free, embeddable Java source interpreter with object scripting language features, written in Java. BeanShell is a natural scripting language for Java. This requires the library bsh-2.0b4.jar to be in classpath. The following example shows using dir command in beanshell script.

File Name  :  
/BEAN_SHELL001/config/dir_content.bsh 
   
dir("C:\\Temp");

dir("C:\\input");
   

File Name  :  
com/bethecoder/tutorials/bean_shell/commands/DirContentTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.bean_shell.commands;

import java.io.InputStreamReader;

import bsh.EvalError;
import bsh.Interpreter;

public class DirContentTest {

  /**
   @param args
   @throws EvalError 
   */
  public static void main(String[] argsthrows EvalError {
    Interpreter interpreter = new Interpreter();
    InputStreamReader reader = new InputStreamReader(
        DirContentTest.class.getClassLoader()
        .getResourceAsStream("dir_content.bsh"));
    
    interpreter.eval(reader);
  }

}
   

It gives the following output,
rw_ Nov 24       42 basic.vm
rw_ Nov 30       27 print.bsh
rw_ Dec 2        64 source_info.bsh
rw_ Nov 23       12 xyz.txt


rw_ Oct 30        1 hidden_file.txt
r-_ Oct 30        1 readonly_file.txt


                    Print

   



Books Recommendation

 
 
bl  br