The file contains this information:
ID# Student’s Answers
---------------------------
236499 TFTFTFTFFFFTFTFFFTF
643828 TFTFTTTTTF FTFTFTTF
917057 FTF FTTTFFFTF FTFTFT
656565 FTF FTFTFTF TTFT TTT
183742 FFTF FFT TFFFTFTFTFF
I have written the code and it compiles well. But when i execute the program it gives me exception errors.
The program reads only upto this place and from here it shows exception errors. My program is not able to read in space that is present in the text file.
ID# Student’s Answers
---------------------------
236499 TFTFTFTFFFFTFTFFFTF
643828 TFTFTTTTTF
Help is needed........pliz
The code i have written for reading this file is:
Expand|Select|Wrap|Line Numbers
- import java.util.*;
- import java.io.*;
- public class read
- {
- public static void main(String[] args) throws IOException
- {
- Scanner inFile = new Scanner(new FileReader("Z:\\StudentResponses.txt"));
- String student_responses;
- String header1, header2;
- int id;
- System.out.println("ID#\tStudent's Answers");
- System.out.println("----------------------------");
- header1 = inFile.nextLine();
- header2 = inFile.nextLine();
- while (inFile.hasNext())
- {
- id = inFile.nextInt();
- student_responses = inFile.next();
- System.out.println(id + "\t" + student_responses);
- }
- inFile.close();
- System.out.println();
- }