Hi,
I'm new to JSP, although I have quite a bit of experience with Java. I wrote a little program that, when provided with a name, it looks for the listing in a file, and prints out the associated line in the file. For example, if I type in 'John' and click submit, it should take that name, give it the program, and in return get something like '32: John Smith student' if that was the appropriate line in the file.
I wrote this as an applet before, which works fine. However, when I tried doing this using an associated Java program, it opens the file, but then does not read anything. My code is below:
Code:
section = section.trim();
student = student.trim();
String fName = "quizMarks" + section + ".txt";
info = "got the info";
try {
info = "entered loop";
BufferedReader br = new BufferedReader(new FileReader(fName));
info = "opened reader";
String info = br.readLine();
info = "replaced";
String grade = br.readLine();
grade = "replaced";
while (grade != null) {
if (grade.indexOf(student) != -1) {
break;
} else {
grade = br.readLine();
}
}
br.close();
if (grade.indexOf(student) == -1) {
grade = "There is no record for you in this section";
}
} catch (Exception e) {
e.printStackTrace();
}
I'm based out of DOS right now, so permissions can't be the answer. And the changing of what info is just lets me check where the error is occurring. It happens at the first time it says 'br.readLine();'