1 21 22 27 28 package com.sun.mail.util; 29 30 import java.io.*; 31 import javax.mail.MessagingException ; 32 33 43 44 public class LineOutputStream extends FilterOutputStream { 45 private static byte[] newline; 46 47 static { 48 newline = new byte[2]; 49 newline[0] = (byte)'\r'; 50 newline[1] = (byte)'\n'; 51 } 52 53 public LineOutputStream(OutputStream out) { 54 super(out); 55 } 56 57 public void writeln(String s) throws MessagingException { 58 try { 59 byte[] bytes = ASCIIUtility.getBytes(s); 60 out.write(bytes); 61 out.write(newline); 62 } catch (Exception ex) { 63 throw new MessagingException ("IOException", ex); 64 } 65 } 66 67 public void writeln() throws MessagingException { 68 try { 69 out.write(newline); 70 } catch (Exception ex) { 71 throw new MessagingException ("IOException", ex); 72 } 73 } 74 } 75 | Popular Tags |