Removed not nessary input/output buffering

This commit is contained in:
M66B
2019-07-26 08:39:05 +02:00
parent c4e29a9539
commit de963c56b7
10 changed files with 35 additions and 47 deletions

View File

@@ -27,7 +27,6 @@ import android.webkit.MimeTypeMap;
import com.sun.mail.util.FolderClosedIOException;
import com.sun.mail.util.MessageRemovedIOException;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
@@ -85,7 +84,6 @@ public class MessageHelper {
static final int SMALL_MESSAGE_SIZE = 32 * 1024; // bytes
static final int ATTACHMENT_BUFFER_SIZE = 8192; // bytes
static final int DEFAULT_ATTACHMENT_DOWNLOAD_SIZE = 256 * 1024; // bytes
static void setSystemProperties() {
@@ -874,7 +872,7 @@ public class MessageHelper {
result = (String) content;
else if (content instanceof InputStream)
// Typically com.sun.mail.util.QPDecoderStream
result = Helper.readStream((InputStream) content, "UTF-8");
result = Helper.readStream((InputStream) content, StandardCharsets.UTF_8.name());
else
result = content.toString();
} catch (IOException | FolderClosedException | MessageRemovedException ex) {
@@ -972,8 +970,8 @@ public class MessageHelper {
long total = apart.part.getSize();
int lastprogress = 0;
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
byte[] buffer = new byte[ATTACHMENT_BUFFER_SIZE];
try (OutputStream os = new FileOutputStream(file)) {
byte[] buffer = new byte[Helper.BUFFER_SIZE];
for (int len = is.read(buffer); len != -1; len = is.read(buffer)) {
size += len;
os.write(buffer, 0, len);