You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by hb...@apache.org on 2002/10/19 21:51:20 UTC

cvs commit: jakarta-james/src/java/org/apache/james/util CRLFPrintWriter.java

hbedi       2002/10/19 12:51:20

  Added:       src/java/org/apache/james/util CRLFPrintWriter.java
  Log:
  printwriter that always ends lines with CRLF. Most protocols require this.
  
  Revision  Changes    Path
  1.1                  jakarta-james/src/java/org/apache/james/util/CRLFPrintWriter.java
  
  Index: CRLFPrintWriter.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  
  package org.apache.james.util;
  
  import java.io.IOException;
  import java.io.OutputStream;
  import java.io.PrintWriter;
  import java.io.Writer;
  
  /**
   * Lines always end with CRLF. Most protocols require this.
   * Don't want to depend on java and OS to do the right thing.
   *
   * Note: method signatures and description exactly matches base
   * class. No point in repeating javadocs. @see base class for method
   * signatures
   */
  public class CRLFPrintWriter extends PrintWriter {
      /** base class has autoFlush variable but it is not exposed */
      private boolean m_autoFlush;
  
      public CRLFPrintWriter (Writer out) {
          this(out,false);
      }
  
      public CRLFPrintWriter(Writer out,boolean autoFlush) {
          super(out,autoFlush);
          m_autoFlush = autoFlush;
      }
  
      public CRLFPrintWriter(OutputStream out) {
          this(out,false);
      }
  
      public CRLFPrintWriter(OutputStream out, boolean autoFlush) {
          super(out,autoFlush);
          m_autoFlush = autoFlush;
      }
  
      public void println() {
          try {
              out.write("\r\n");
              if ( m_autoFlush )
                  out.flush();
          } catch(IOException ex) {
              throw new RuntimeException(ex.toString());
          }
      }
  }
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>