CRLFOutputStreampublic class CRLFOutputStream extends FilterOutputStream Convert lines into the canonical format, that is, terminate lines with the
CRLF sequence. |
Fields Summary |
---|
protected int | lastb | protected boolean | atBOL | private static final byte[] | newline |
Constructors Summary |
---|
public CRLFOutputStream(OutputStream os)
super(os);
|
Methods Summary |
---|
public void | write(int b)
if (b == '\r") {
writeln();
} else if (b == '\n") {
if (lastb != '\r")
writeln();
} else {
out.write(b);
atBOL = false;
}
lastb = b;
| public void | write(byte[] b)
write(b, 0, b.length);
| public void | write(byte[] b, int off, int len)
int start = off;
len += off;
for (int i = start; i < len ; i++) {
if (b[i] == '\r") {
out.write(b, start, i - start);
writeln();
start = i + 1;
} else if (b[i] == '\n") {
if (lastb != '\r") {
out.write(b, start, i - start);
writeln();
}
start = i + 1;
}
lastb = b[i];
}
if ((len - start) > 0) {
out.write(b, start, len - start);
atBOL = false;
}
| public void | writeln()
out.write(newline);
atBOL = true;
|
|