Class QuotedPrintableOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class QuotedPrintableOutputStream
    extends java.io.FilterOutputStream
    Performs Quoted-Printable encoding on an underlying stream. Encodes every "required" char plus the dot ".". We encode the dot by default because this is a workaround for some "filter"/"antivirus" "old mua" having issues with dots at the beginning or the end of a qp encode line (maybe a bad dot-destuffing algo).
    • Field Detail

      • QUOTED_PRINTABLE_LAST_PLAIN

        private static final byte QUOTED_PRINTABLE_LAST_PLAIN
        See Also:
        Constant Field Values
      • QUOTED_PRINTABLE_MAX_LINE_LENGTH

        private static final int QUOTED_PRINTABLE_MAX_LINE_LENGTH
        See Also:
        Constant Field Values
      • QUOTED_PRINTABLE_OCTETS_PER_ESCAPE

        private static final int QUOTED_PRINTABLE_OCTETS_PER_ESCAPE
        See Also:
        Constant Field Values
      • HEX_DIGITS

        private static final byte[] HEX_DIGITS
      • outBuffer

        private final byte[] outBuffer
      • binary

        private final boolean binary
      • pendingSpace

        private boolean pendingSpace
      • pendingTab

        private boolean pendingTab
      • pendingCR

        private boolean pendingCR
      • nextSoftBreak

        private int nextSoftBreak
      • outputIndex

        private int outputIndex
      • closed

        private boolean closed
      • singleByte

        private final byte[] singleByte
    • Constructor Detail

      • QuotedPrintableOutputStream

        public QuotedPrintableOutputStream​(int bufsize,
                                           java.io.OutputStream out,
                                           boolean binary)
      • QuotedPrintableOutputStream

        public QuotedPrintableOutputStream​(java.io.OutputStream out,
                                           boolean binary)
    • Method Detail

      • encodeChunk

        private void encodeChunk​(byte[] buffer,
                                 int off,
                                 int len)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • completeEncoding

        private void completeEncoding()
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writePending

        private void writePending()
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • clearPending

        private void clearPending()
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • encode

        private void encode​(byte next)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • plain

        private void plain​(byte next)
                    throws java.io.IOException
        Throws:
        java.io.IOException
      • escape

        private void escape​(byte next)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        private void write​(byte next)
                    throws java.io.IOException
        Throws:
        java.io.IOException
      • softBreak

        private void softBreak()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • lineBreak

        private void lineBreak()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • flushOutput

        void flushOutput()
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • write

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

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