|
3 | 3 | import com.sun.mail.handlers.text_plain; |
4 | 4 | import org.jetbrains.annotations.NotNull; |
5 | 5 | import org.jetbrains.annotations.Nullable; |
| 6 | +import org.simplejavamail.internal.util.MiscUtil; |
6 | 7 | import org.simplejavamail.internal.util.Preconditions; |
7 | 8 |
|
8 | 9 | import javax.activation.ActivationDataFlavor; |
|
25 | 26 | import javax.mail.internet.MimeUtility; |
26 | 27 | import javax.mail.internet.ParseException; |
27 | 28 | import javax.mail.util.ByteArrayDataSource; |
28 | | -import java.io.BufferedInputStream; |
29 | | -import java.io.BufferedOutputStream; |
30 | | -import java.io.ByteArrayOutputStream; |
31 | 29 | import java.io.IOException; |
32 | 30 | import java.io.InputStream; |
33 | 31 | import java.io.UnsupportedEncodingException; |
@@ -387,19 +385,8 @@ private static String decodeText(@NotNull final String result) { |
387 | 385 |
|
388 | 386 | @NotNull |
389 | 387 | private static byte[] readContent(@NotNull final InputStream is) { |
390 | | - final BufferedInputStream isReader = new BufferedInputStream(is); |
391 | | - final ByteArrayOutputStream os = new ByteArrayOutputStream(); |
392 | | - final BufferedOutputStream osWriter = new BufferedOutputStream(os); |
393 | | - |
394 | | - int ch; |
395 | 388 | try { |
396 | | - while ((ch = isReader.read()) != -1) { |
397 | | - osWriter.write(ch); |
398 | | - } |
399 | | - osWriter.flush(); |
400 | | - final byte[] result = os.toByteArray(); |
401 | | - osWriter.close(); |
402 | | - return result; |
| 389 | + return MiscUtil.readInputStreamToBytes(is); |
403 | 390 | } catch (final IOException e) { |
404 | 391 | throw new MimeMessageParseException(MimeMessageParseException.ERROR_READING_CONTENT, e); |
405 | 392 | } |
|
0 commit comments