/*
	Tom DeDonno page 591

	Reads first two lines from data.txt
	and prints them out at screen
	
	Demonstrates BufferedReader and FileReader
*/

import java.io.*; //for BufferedReader and FileReader

public class TextFileInputDemo {


	public static void main( String[] args ) {

		String fileName = "data.txt"; // out1.txt
		try {

			// Can fileName declaration be put here?
			
			BufferedReader inputStream =
			new BufferedReader( new FileReader( fileName ) );
                        //Throws FileNOtFoundException

			String line = (String)null;
                        
			line = inputStream.readLine( ); // Throws IOException
			System.out.println( "First Line in " + fileName );
			System.out.println( line );
			
			line = inputStream.readLine( );
			System.out.println( "Second Line in " + fileName );
			System.out.println( line );

			//Do we need to do this
			inputStream.close( );
		
		} catch( FileNotFoundException e ) {
		System.out.println( "File " + fileName + " was not found");
		System.out.println( " or could not be opened" );
		
		} catch( IOException e ) {
		System.out.println( "Error reading from file " + fileName );
		} 

	} //End main
} //end class

		 
