Wrap an encoder around the given output 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 os output stream @param encoding the encoding of the stream. @return
(OutputStream os, String encoding)
| 396 | * @exception MessagingException if the encoding is unknown |
| 397 | */ |
| 398 | public static OutputStream encode(OutputStream os, String encoding) |
| 399 | throws MessagingException { |
| 400 | if (encoding == null) |
| 401 | return os; |
| 402 | else if (encoding.equalsIgnoreCase("base64")) |
| 403 | return new BASE64EncoderStream(os); |
| 404 | else if (encoding.equalsIgnoreCase("quoted-printable")) |
| 405 | return new QPEncoderStream(os); |
| 406 | else if (encoding.equalsIgnoreCase("uuencode") || |
| 407 | encoding.equalsIgnoreCase("x-uuencode") || |
| 408 | encoding.equalsIgnoreCase("x-uue")) |
| 409 | return new UUEncoderStream(os); |
| 410 | else if (encoding.equalsIgnoreCase("binary") || |
| 411 | encoding.equalsIgnoreCase("7bit") || |
| 412 | encoding.equalsIgnoreCase("8bit")) |
| 413 | return os; |
| 414 | else |
| 415 | throw new MessagingException("Unknown encoding: " +encoding); |
| 416 | } |
| 417 | |
| 418 | /** |
| 419 | * Wrap an encoder around the given output stream. |
no outgoing calls
no test coverage detected