import java.io.*;

/******************************************************************************
 * Read from a file using char (16bit) I/O, and prints to screen
 *    
 * If input  file does not exist --> FileNotFounDException
 *
 * Instantiate a File to get a file handle.
 * Instantiate a FileReader to open the file for input.
 * Instantiate a BufferedReader to buffer the read operation. 
 *****************************************************************************/

public class IOfile2a
{
    public static void main(String[] args)
    {

        String input_file  = "../data/temp.txt";                    //relative path

//      String input_file  = "/home/sultans/web/java/demo/8inpout/data/temp.txt";

        try 
        {
            File           file1    = new File(input_file);         //create a file handle  
            FileReader     inFile   = new FileReader(file1);        //open file1 for input
            BufferedReader inBuffer = new BufferedReader(inFile);   //buffer the input
        
            while(true)
            {
                String input = inBuffer.readLine();     //read a line

                if (input == null)                      //end-of-file?
                    break;

                System.out.println(input);              //print the line
            }
                
            inFile.close();
        }

        catch (FileNotFoundException e)
        {
            System.out.println(e);              //print exception message
            e.printStackTrace(System.err);      //print pgm trace to error output 
        }
        catch (IOException e)
        {
            System.out.println(e);
        }       
    }
}