use of android.util.Base64DataException in project android_packages_apps_Dialer by LineageOS.
the class MimeUtility method decodeBody.
/**
* Removes any content transfer encoding from the stream and returns a Body.
*/
public static Body decodeBody(InputStream in, String contentTransferEncoding) throws IOException {
/*
* We'll remove any transfer encoding by wrapping the stream.
*/
in = getInputStreamForContentTransferEncoding(in, contentTransferEncoding);
BinaryTempFileBody tempBody = new BinaryTempFileBody();
OutputStream out = tempBody.getOutputStream();
try {
IOUtils.copy(in, out);
} catch (Base64DataException bde) {
// TODO Need to fix this somehow
// String warning = "\n\n" + Email.getMessageDecodeErrorString();
// out.write(warning.getBytes());
} finally {
out.close();
}
return tempBody;
}
use of android.util.Base64DataException in project android_packages_apps_Dialer by LineageOS.
the class ImapFolder method decodeBody.
/**
* Removes any content transfer encoding from the stream and returns a Body. This code is
* taken/condensed from MimeUtility.decodeBody
*/
private static Body decodeBody(Context context, InputStream in, String contentTransferEncoding, int size, MessageRetrievalListener listener) throws IOException {
// Get a properly wrapped input stream
in = MimeUtility.getInputStreamForContentTransferEncoding(in, contentTransferEncoding);
BinaryTempFileBody tempBody = new BinaryTempFileBody();
OutputStream out = tempBody.getOutputStream();
try {
byte[] buffer = new byte[COPY_BUFFER_SIZE];
int n = 0;
int count = 0;
while (-1 != (n = in.read(buffer))) {
out.write(buffer, 0, n);
count += n;
}
} catch (Base64DataException bde) {
String warning = "\n\nThere was an error while decoding the message.";
out.write(warning.getBytes());
} finally {
out.close();
}
return tempBody;
}
Aggregations