
//==============================================================================
//
//  File name ......: ReadingFromInputFile.java
//  Author(s) ......: Leen-Kiat Soh
//  Language .......: Java
//  Started ........: February 1 2004
//  Last modified ..: February 3 2004
//  Version ........: 1.0
//  Source Path ....: .
//  Site ...........: Department of Computer Science and Engineering
//                    University of Nebraska
//                    Lincoln, NE 68588-0115
//                    U.S.A.
//  Purpose ........: This reads in several lines of tokens until it reads
//		      "END".  This is not a complete program.  It simply shows
//		      how to read from an input file and how to extract the
//		      tokens from each line.
//  Note ...........: Adapted from a program originally written by Preston 
//		      Mesick
//==============================================================================

import java.io.*;
import java.util.*;

public class ReadingFromInputFile {
      
    public ReadingFromInputFile() {
    }
    
    public static void main(String[] args) throws IOException
    {
        StringTokenizer parser;
        
        try {     
            
		// sets up the file to be read from
            File inFile = new File(args[0]);       
            FileReader fileReader = new FileReader(inFile);
            BufferedReader reader = new BufferedReader(fileReader);
            
            String tempStr = new String();
            String [] members = new String[50];
            
            tempStr = reader.readLine();
            while (!(tempStr.equalsIgnoreCase("END")))
            {
                parser = new StringTokenizer(tempStr, " ");
                members[0] = parser.nextToken();
                for (int i = 1; parser.hasMoreTokens(); i++)
                	  members[i] = parser.nextToken();
            
                tempStr = reader.readLine();
            } // while
         }  
         catch(IOException e)
         {
                System.err.println( "IOException occurred: " + 
                                e.getMessage());
         } // catch
    } 
    
}

