FileDocCategorySizeDatePackage
CRLFOutputStream.javaAPI DocGlassfish v2 API3421Mon May 14 15:28:46 BST 2007com.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;