2014-12-14 10:28:42 -05:00
|
|
|
package com.fsck.k9.mailstore;
|
2014-09-07 08:54:02 -04:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2014-09-22 15:55:08 -04:00
|
|
|
/**
|
|
|
|
* An attachment whose contents are contained in a file.
|
|
|
|
*/
|
2014-09-07 08:54:02 -04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2014-12-11 18:32:38 -05:00
|
|
|
}
|