Presented below is a simple example which reads the file (whose name is given as an argument from command prompt) and prints out its contents.

Java Code:
import java.io.*;
public class Reader{
  public static void main (String args[]) {
    String thisLine;
    for (int i=0; i < args.length; i++) {
       try {
          FileInputStream fin =  new FileInputStream(args[i]);
          BufferedReader myInput = new BufferedReader
              (new InputStreamReader(fin));
          while ((thisLine = myInput.readLine()) != null) {  
             System.out.println(thisLine);
             }
          }
       catch (Exception e) {
         e.printStackTrace();
         }
       }
    } 
}