Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 10th, 2003, 04:34 PM
Registered User
 
Join Date: Aug 2003
Location: , , Canada.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default reading files

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();'



Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading large files ravichandrae Pro Java 1 January 11th, 2008 04:42 AM
Reading text files senthilreddy ASP.NET 2.0 Basics 1 May 22nd, 2007 08:32 AM
Reading files from thumbdrive. karatekarthi Java Basics 2 May 16th, 2007 08:25 AM
Reading from Excel Files interrupt Javascript How-To 8 September 28th, 2006 09:31 AM
Reading .ini files anisurr C++ Programming 2 February 7th, 2006 05:02 PM



All times are GMT -4. The time now is 09:27 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.