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.
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.
no subject
Date: 2004-05-09 05:00 pm (UTC)From:FileReader input; int c; String line="";
do {
try { c = input.read(); } catch (java.io.IOException e) { c = -1 }
if (c == -1) break;
if (c == (int)('\n')) break;
line = line + ((char)c);
} while (true);
PS - Watch for the evil blank line at #87, the spurious '\'s and the fact that the calendar line is broken for Easter term...
Cool
Date: 2004-05-10 01:55 am (UTC)From:I love those things.
no subject
Date: 2004-05-10 04:04 am (UTC)From: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();
}
}