1 21 22 27 28 package javax.mail.internet; 29 30 import java.io.*; 31 import java.util.Enumeration ; 32 import javax.mail.*; 33 34 import com.sun.mail.util.LineOutputStream; 35 36 49 50 public class PreencodedMimeBodyPart extends MimeBodyPart { 51 private String encoding; 52 53 58 public PreencodedMimeBodyPart(String encoding) { 59 this.encoding = encoding; 60 } 61 62 66 public String getEncoding() throws MessagingException { 67 return encoding; 68 } 69 70 79 public void writeTo(OutputStream os) 80 throws IOException, MessagingException { 81 82 LineOutputStream los = null; 84 if (os instanceof LineOutputStream) { 85 los = (LineOutputStream) os; 86 } else { 87 los = new LineOutputStream(os); 88 } 89 90 Enumeration hdrLines = getAllHeaderLines(); 92 while (hdrLines.hasMoreElements()) 93 los.writeln((String )hdrLines.nextElement()); 94 95 los.writeln(); 97 98 getDataHandler().writeTo(os); 100 os.flush(); 101 } 102 103 107 protected void updateHeaders() throws MessagingException { 108 super.updateHeaders(); 109 MimeBodyPart.setEncoding(this, encoding); 110 } 111 } 112 | Popular Tags |