Steen,
How's this work for you?
public void write(int b) throws IOException { switch (b) { case '.': if (countLast0A0D == 2) { out.write('.'); } countLast0A0D = 0; break; case '\r': countLast0A0D = 1; break; case '\n': if (countLast0A0D == 1) { countLast0A0D = 2; } else { out.write('\r'); countLast0A0D = 0; } break; default: countLast0A0D = 0; break; } out.write(b); }
The problem that I have with it now is that although it converts a naked LF to CRLF, it won't double the '.' after a line that improperly begins with just LF.
--- Noel
It works, but you are right that it won't double the '.' after a LF terminated line.
Couldn't it be fixed with a little change?
public void write(int b) throws IOException {
switch (b) {
case '.':
if (countLast0A0D == 2) {
out.write('.');
}
countLast0A0D = 0;
break;
case '\r':
countLast0A0D = 1;
break;
case '\n':
if (countLast0A0D == 1) {
countLast0A0D = 2;
} else {
out.write('\r');
// countLast0A0D = 0; // Change this
countLast0A0D = 2; // into this
}
break;
default:
countLast0A0D = 0;
break;
}
out.write(b);
}Steen
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
