chess: (the fire in her eyes masked the fear)
Have eaten whole 6-pack of scotch pancakes. Have still not finished Tick 7. BufferedReader's readLine method appears to be disagreeing with text files without a line break at the end. Naturally, this text file is one without a line break at the end. There are ways round this, but they are a Royal Pain in the Ass.

It is probably too late for me to be working. Have done no supervision work for tomorrow. This mildly annoys me, because I could have done with doing the maths work, as I'm currently on course for Failing Maths Horribly.

Date: 2004-05-10 04:04 am (UTC)From: [identity profile] jaq.livejournal.com
Even if you're reading by character, it's still worth wrapping the FileReader with a BufferedReader for efficiency.

But readLine() works fine for me on a file with no lineend at the end, so I'm not sure why it's a problem.
My example:
public static void main(String[] args) {
try {
BufferedReader rd = new BufferedReader(new FileReader("c:/working/testfile.txt"));
String line;
while((line = rd.readLine()) != null) {
System.out.println(line);
}
System.out.println("[EOF]");
} catch(Exception e) {
System.out.println("caught exception " + e.getMessage());
e.printStackTrace();
}
}

Profile

chess: (Default)
Michelle Taylor

January 2025

S M T W T F S
   1234
567891011
12131415161718
19202122232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 4th, 2026 04:38 am
Powered by Dreamwidth Studios