import java.io.*;
class ReadFile {
public static void main(String args[]) throws IOException {
String Names[] = new String[3];
int Ages[] = new int[3];
String line = new String();
int i;
//openup file in FileReader
FileReader file_input = new FileReader("data.txt");
//create BufferedReader from FileReader
BufferedReader BR = new BufferedReader(file_input);
//Read the 6 input lines of alternating Names and Age info
for(i=0; i<3; i++)
{
Names[i] = BR.readLine();
line = BR.readLine();
Ages[i] = (Integer.valueOf(line)).intValue( );
}
//Print out information
for(i=0;i<3; i++)
System.out.println("Data" + i + " " + Names[i] + " " + Ages[i]);
//Close streams
BR.close();
file_input.close();
}
}
|