mirror of
https://github.com/moparisthebest/k-9
synced 2024-08-13 17:03:48 -04:00
30 lines
752 B
Java
30 lines
752 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;
|
|
|
|
/**
|
|
* An attachment whose contents are contained in a file.
|
|
*/
|
|
public class TempFileBody extends BinaryAttachmentBody {
|
|
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);
|
|
}
|
|
}
|
|
}
|