return new BASE64DecoderStream(is); else if (encoding.equalsIgnoreCase("quoted-printable")) return new QPDecoderStream(is); else if (encoding.equalsIgnoreCase("uuencode") || encoding.equalsIgnoreCase("x-uuencode") ||
/** * Skips over and discards n bytes of data from this stream. */ public long skip(long n) throws IOException { long skipped = 0; while (n-- > 0 && read() >= 0) skipped++; return skipped; }
/** * Skips over and discards n bytes of data from this stream. */ @Override public long skip(long n) throws IOException { long skipped = 0; while (n-- > 0 && read() >= 0) skipped++; return skipped; }
return new BASE64DecoderStream(is); else if (encoding.equalsIgnoreCase("quoted-printable")) return new QPDecoderStream(is); else if (encoding.equalsIgnoreCase("uuencode") || encoding.equalsIgnoreCase("x-uuencode") ||
/** * Reads up to <code>len</code> decoded bytes of data from this input stream * into an array of bytes. This method blocks until some input is * available. * <p> * * @param buf the buffer into which the data is read. * @param off the start offset of the data. * @param len the maximum number of bytes read. * @return the total number of bytes read into the buffer, or * <code>-1</code> if there is no more data because the end of * the stream has been reached. * @exception IOException if an I/O error occurs. */ public int read(byte[] buf, int off, int len) throws IOException { int i, c; for (i = 0; i < len; i++) { if ((c = read()) == -1) { if (i == 0) // At end of stream, so we should i = -1; // return -1 , NOT 0. break; } buf[off+i] = (byte)c; } return i; }
return new BASE64DecoderStream(is); else if (encoding.equalsIgnoreCase("quoted-printable")) return new QPDecoderStream(is); else if (encoding.equalsIgnoreCase("uuencode") || encoding.equalsIgnoreCase("x-uuencode") ||
/** * Reads up to <code>len</code> decoded bytes of data from this input stream * into an array of bytes. This method blocks until some input is * available. * <p> * * @param buf the buffer into which the data is read. * @param off the start offset of the data. * @param len the maximum number of bytes read. * @return the total number of bytes read into the buffer, or * <code>-1</code> if there is no more data because the end of * the stream has been reached. * @exception IOException if an I/O error occurs. */ @Override public int read(byte[] buf, int off, int len) throws IOException { int i, c; for (i = 0; i < len; i++) { if ((c = read()) == -1) { if (i == 0) // At end of stream, so we should i = -1; // return -1 , NOT 0. break; } buf[off+i] = (byte)c; } return i; }
return new BASE64DecoderStream(is); else if (encoding.equalsIgnoreCase("quoted-printable")) return new QPDecoderStream(is); else if (encoding.equalsIgnoreCase("uuencode") || encoding.equalsIgnoreCase("x-uuencode") ||
/** * Decode the given input stream. The Input stream returned is * the decoded input stream. All the encodings defined in RFC 2045 * are supported here. They include "base64", "quoted-printable", * "7bit", "8bit", and "binary". In addition, "uuencode" is also * supported. * * @param is input stream * @param encoding the encoding of the stream. * @return decoded input stream. */ public static InputStream decode(InputStream is, String encoding) throws MessagingException { if (encoding.equalsIgnoreCase("base64")) return new BASE64DecoderStream(is); else if (encoding.equalsIgnoreCase("quoted-printable")) return new QPDecoderStream(is); else if (encoding.equalsIgnoreCase("uuencode") || encoding.equalsIgnoreCase("x-uuencode") || encoding.equalsIgnoreCase("x-uue")) return new UUDecoderStream(is); else if (encoding.equalsIgnoreCase("binary") || encoding.equalsIgnoreCase("7bit") || encoding.equalsIgnoreCase("8bit")) return is; else throw new MessagingException("Unknown encoding: " + encoding); }
return new BASE64DecoderStream(is); else if (encoding.equalsIgnoreCase("quoted-printable")) return new QPDecoderStream(is); else if (encoding.equalsIgnoreCase("uuencode") || encoding.equalsIgnoreCase("x-uuencode") ||
/** * Skips over and discards n bytes of data from this stream. */ @Override public long skip(long n) throws IOException { long skipped = 0; while (n-- > 0 && read() >= 0) skipped++; return skipped; }
return new BASE64DecoderStream(is); else if (encoding.equalsIgnoreCase("quoted-printable")) return new QPDecoderStream(is); else if (encoding.equalsIgnoreCase("uuencode") || encoding.equalsIgnoreCase("x-uuencode") ||
/** * Skips over and discards n bytes of data from this stream. */ @Override public long skip(long n) throws IOException { long skipped = 0; while (n-- > 0 && read() >= 0) skipped++; return skipped; }
return new BASE64DecoderStream(is); else if (encoding.equalsIgnoreCase("quoted-printable")) return new QPDecoderStream(is); else if (encoding.equalsIgnoreCase("uuencode") || encoding.equalsIgnoreCase("x-uuencode") ||
/** * Skips over and discards n bytes of data from this stream. */ @Override public long skip(long n) throws IOException { long skipped = 0; while (n-- > 0 && read() >= 0) skipped++; return skipped; }
return new BASE64DecoderStream(is); else if (encoding.equalsIgnoreCase("quoted-printable")) return new QPDecoderStream(is); else if (encoding.equalsIgnoreCase("uuencode") || encoding.equalsIgnoreCase("x-uuencode") ||
/** * Skips over and discards n bytes of data from this stream. */ public long skip(long n) throws IOException { long skipped = 0; while (n-- > 0 && read() >= 0) skipped++; return skipped; }
return new BASE64DecoderStream(is); else if (encoding.equalsIgnoreCase("quoted-printable")) return new QPDecoderStream(is); else if (encoding.equalsIgnoreCase("uuencode") || encoding.equalsIgnoreCase("x-uuencode") ||