mirror of https://github.com/moparisthebest/k-9
43 lines
1.0 KiB
Java
43 lines
1.0 KiB
Java
package com.fsck.k9.mailstore;
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.OutputStream;
|
|
|
|
import com.fsck.k9.mail.Body;
|
|
import com.fsck.k9.mail.MessagingException;
|
|
import com.fsck.k9.mail.internet.RawDataBody;
|
|
|
|
|
|
public class BinaryMemoryBody implements Body, RawDataBody {
|
|
private final byte[] data;
|
|
private final String encoding;
|
|
|
|
public BinaryMemoryBody(byte[] data, String encoding) {
|
|
this.data = data;
|
|
this.encoding = encoding;
|
|
}
|
|
|
|
@Override
|
|
public String getEncoding() {
|
|
return encoding;
|
|
}
|
|
|
|
@Override
|
|
public InputStream getInputStream() throws MessagingException {
|
|
return new ByteArrayInputStream(data);
|
|
}
|
|
|
|
@Override
|
|
public void setEncoding(String encoding) throws UnavailableStorageException, MessagingException {
|
|
throw new RuntimeException("nope"); //FIXME
|
|
}
|
|
|
|
@Override
|
|
public void writeTo(OutputStream out) throws IOException, MessagingException {
|
|
out.write(data);
|
|
}
|
|
}
|