com.sun.mail.smtp
Class SMTPOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by com.sun.mail.util.CRLFOutputStream
              extended by com.sun.mail.smtp.SMTPOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class SMTPOutputStream
extends CRLFOutputStream

In addition to converting lines into the canonical format, i.e., terminating lines with the CRLF sequence, escapes the "." by adding another "." to any "." that appears in the beginning of a line. See RFC821 section 4.5.2.

Author:
Max Spivak
See Also:
CRLFOutputStream

Field Summary
 
Fields inherited from class com.sun.mail.util.CRLFOutputStream
atBOL, lastb
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
SMTPOutputStream(java.io.OutputStream os)
           
 
Method Summary
 void ensureAtBOL()
          Ensure we're at the beginning of a line.
 void flush()
          Override flush method in FilterOutputStream.
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class com.sun.mail.util.CRLFOutputStream
write, writeln
 
Methods inherited from class java.io.FilterOutputStream
close
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SMTPOutputStream

public SMTPOutputStream(java.io.OutputStream os)
Method Detail

write

public void write(int b)
           throws java.io.IOException
Overrides:
write in class CRLFOutputStream
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Overrides:
write in class CRLFOutputStream
Throws:
java.io.IOException

flush

public void flush()
Override flush method in FilterOutputStream. The MimeMessage writeTo method flushes its buffer at the end, but we don't want to flush data out to the socket until we've also written the terminating "\r\n.\r\n". We buffer nothing so there's nothing to flush. We depend on the fact that CRLFOutputStream also buffers nothing. SMTPTransport will manually flush the socket before reading the response.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.FilterOutputStream

ensureAtBOL

public void ensureAtBOL()
                 throws java.io.IOException
Ensure we're at the beginning of a line. Write CRLF if not.

Throws:
java.io.IOException


Copyright © 2011. All Rights Reserved.