1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00
k-9/src/com/fsck/k9/mail/transport/EOLConvertingOutputStream.java

34 lines
754 B
Java
Raw Normal View History

2008-10-27 21:22:17 -04:00
package com.fsck.k9.mail.transport;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class EOLConvertingOutputStream extends FilterOutputStream {
int lastChar;
public EOLConvertingOutputStream(OutputStream out) {
super(out);
}
@Override
public void write(int oneByte) throws IOException {
if (oneByte == '\n') {
if (lastChar != '\r') {
super.write('\r');
}
}
super.write(oneByte);
lastChar = oneByte;
}
@Override
public void flush() throws IOException {
if (lastChar == '\r') {
super.write('\n');
lastChar = '\n';
}
super.flush();
}
}