From 612c48654086058e91ff8977d8b68426c5dc4ba5 Mon Sep 17 00:00:00 2001 From: mguessan Date: Tue, 20 Feb 2007 13:41:56 +0000 Subject: [PATCH] fix BASE64EncoderStream : must pad on flush instead of close git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@29 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/exchange/BASE64EncoderStream.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/java/davmail/exchange/BASE64EncoderStream.java b/src/java/davmail/exchange/BASE64EncoderStream.java index f17c9a52..0ab0402e 100644 --- a/src/java/davmail/exchange/BASE64EncoderStream.java +++ b/src/java/davmail/exchange/BASE64EncoderStream.java @@ -46,12 +46,12 @@ public class BASE64EncoderStream extends FilterOutputStream { /** * The internal buffer of encoded output bytes. **/ - private byte output[] = new byte[4]; + private byte[] output = new byte[4]; /** * The internal buffer of input bytes to be encoded. **/ - private byte input[] = new byte[3]; + private byte[] input = new byte[3]; /** * The index of the next position in the internal buffer of input bytes @@ -100,6 +100,11 @@ public class BASE64EncoderStream extends FilterOutputStream { maxLineLength = max; } + public void flush() throws IOException { + pad(); + out.flush(); + } + /** * Completes the encoding of data, padding the input data if necessary * to end the input on a multiple of 4 bytes, writes a terminating @@ -111,12 +116,9 @@ public class BASE64EncoderStream extends FilterOutputStream { public void close() throws IOException { try { flush(); - } - catch (IOException ignored) { + } catch (IOException ignored) { } - // Make sure the number of bytes output is a multiple of three. - pad(); // Add a terminating CRLF sequence. out.write('\r');