1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00
k-9/k9mail/src/main/java/com/fsck/k9/mailstore/TempFileBody.java
cketti 378acbd313 Write large message parts to file system
Actually, we just move the temporary file to avoid having to copy the
data to a new file.
2015-01-25 19:25:00 +01:00

37 lines
898 B
Java

package com.fsck.k9.mailstore;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.internet.SizeAware;
/**
* An attachment whose contents are contained in a file.
*/
public class TempFileBody extends BinaryAttachmentBody implements SizeAware {
private final File mFile;
public TempFileBody(String filename) {
mFile = new File(filename);
}
@Override
public InputStream getInputStream() throws MessagingException {
try {
return new FileInputStream(mFile);
} catch (FileNotFoundException e) {
return new ByteArrayInputStream(LocalStore.EMPTY_BYTE_ARRAY);
}
}
@Override
public long getSize() {
return mFile.length();
}
}