FileDocCategorySizeDatePackage
CRLFOutputStream.javaAPI DocJavaMail 1.4.33370Tue Nov 17 10:38:12 GMT 2009com.sun.mail.util

CRLFOutputStream

public class CRLFOutputStream extends FilterOutputStream
Convert lines into the canonical format, that is, terminate lines with the CRLF sequence.
author
John Mani

Fields Summary
protected int
lastb
protected boolean
atBOL
private static final byte[]
newline
Constructors Summary
public CRLFOutputStream(OutputStream os)


       
	super(os);
    
Methods Summary
public voidwrite(int b)

	if (b == '\r") {
	    writeln();
	} else if (b == '\n") {
	    if (lastb != '\r")
		writeln();
	} else {
	    out.write(b);
	    atBOL = false;
	}
	lastb = b;
    
public voidwrite(byte[] b)

	write(b, 0, b.length);
    
public voidwrite(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 voidwriteln()

        out.write(newline);
	atBOL = true;