@Test public void testEncode() throws IOException { ByteArrayOutputStream bos; QuotedPrintableOutputStream encoder; bos = new ByteArrayOutputStream(); encoder = new QuotedPrintableOutputStream(bos, false); encoder.write(fromString("This is the plain text message containing a few euros: 100 \u20ac!")); encoder.close(); Assert.assertEquals("This is the plain text message containing a few euros: 100 =E2=82=AC!", toString(bos.toByteArray())); }
private void encode(byte next) throws IOException { if (next == LF) { if (binary) { writePending(); escape(next); } else { if (pendingCR) { if (pendingSpace) { escape(SP); } else if (pendingTab) { escape(TB); } lineBreak(); clearPending(); } else { writePending(); plain(next); } } } else if (next == CR) { if (binary) { escape(next); } else { pendingCR = true; } } else { writePending(); if (next == SP) { if (binary) { escape(next); } else { pendingSpace = true; } } else if (next == TB) { if (binary) { escape(next); } else { pendingTab = true; } } else if (next < SP) { escape(next); } else if (next > QUOTED_PRINTABLE_LAST_PLAIN) { escape(next); } else if (next == EQ || next == DOT) { escape(next); } else { plain(next); } } }
QuotedPrintableOutputStream extends FilterOutputStream { private void encode(byte next) throws IOException { if (next == LF) { if (binary) { writePending(); escape(next); } else { if (pendingCR) { if (pendingSpace) { escape(SP); } else if (pendingTab) { escape(TB); } lineBreak(); clearPending(); } else { writePending(); plain(next); } } } else if (next == CR) { if (binary) { escape(next); } else { pendingCR = true; } } else { writePending(); if (next == SP) { if (binary) { escape(next); } else { pendingSpace = true; } } else if (next == TB) { if (binary) { escape(next); } else { pendingTab = true; } } else if (next < SP) { escape(next); } else if (next > QUOTED_PRINTABLE_LAST_PLAIN) { escape(next); } else if (next == EQ || next == DOT) { escape(next); } else { plain(next); } } } }
QuotedPrintableOutputStream extends FilterOutputStream { private void encode(byte next) throws IOException { if (next == LF) { if (binary) { writePending(); escape(next); } else { if (pendingCR) { if (pendingSpace) { escape(SP); } else if (pendingTab) { escape(TB); } lineBreak(); clearPending(); } else { writePending(); plain(next); } } } else if (next == CR) { if (binary) { escape(next); } else { pendingCR = true; } } else { writePending(); if (next == SP) { if (binary) { escape(next); } else { pendingSpace = true; } } else if (next == TB) { if (binary) { escape(next); } else { pendingTab = true; } } else if (next < SP) { escape(next); } else if (next > QUOTED_PRINTABLE_LAST_PLAIN) { escape(next); } else if (next == EQ || next == DOT) { escape(next); } else { plain(next); } } } QuotedPrintableOutputStream(int bufsize, OutputStream out, boolean binary);  QuotedPrintableOutputStream(OutputStream out, boolean binary); }
QuotedPrintableOutputStream extends FilterOutputStream { private void encode(byte next) throws IOException { if (next == LF) { if (binary) { writePending(); escape(next); } else { if (pendingCR) { if (pendingSpace) { escape(SP); } else if (pendingTab) { escape(TB); } lineBreak(); clearPending(); } else { writePending(); plain(next); } } } else if (next == CR) { if (binary) { escape(next); } else { pendingCR = true; } } else { writePending(); if (next == SP) { if (binary) { escape(next); } else { pendingSpace = true; } } else if (next == TB) { if (binary) { escape(next); } else { pendingTab = true; } } else if (next < SP) { escape(next); } else if (next > QUOTED_PRINTABLE_LAST_PLAIN) { escape(next); } else if (next == EQ || next == DOT) { escape(next); } else { plain(next); } } } QuotedPrintableOutputStream(int bufsize, OutputStream out, boolean binary);  QuotedPrintableOutputStream(OutputStream out, boolean binary); @Override void close(); @Override void flush(); @Override void write(int b); @Override void write(byte[] b, int off, int len); }
QuotedPrintableOutputStream extends FilterOutputStream { private void encode(byte next) throws IOException { if (next == LF) { if (binary) { writePending(); escape(next); } else { if (pendingCR) { if (pendingSpace) { escape(SP); } else if (pendingTab) { escape(TB); } lineBreak(); clearPending(); } else { writePending(); plain(next); } } } else if (next == CR) { if (binary) { escape(next); } else { pendingCR = true; } } else { writePending(); if (next == SP) { if (binary) { escape(next); } else { pendingSpace = true; } } else if (next == TB) { if (binary) { escape(next); } else { pendingTab = true; } } else if (next < SP) { escape(next); } else if (next > QUOTED_PRINTABLE_LAST_PLAIN) { escape(next); } else if (next == EQ || next == DOT) { escape(next); } else { plain(next); } } } QuotedPrintableOutputStream(int bufsize, OutputStream out, boolean binary);  QuotedPrintableOutputStream(OutputStream out, boolean binary); @Override void close(); @Override void flush(); @Override void write(int b); @Override void write(byte[] b, int off, int len);  }