FileDocCategorySizeDatePackage
MemoryTextBody.javaAPI DocAndroid 1.5 API4555Wed May 06 22:42:46 BST 2009org.apache.james.mime4j.message

MemoryTextBody

public class MemoryTextBody extends AbstractBody implements TextBody
Text body backed by a {@link org.apache.james.mime4j.util.TempFile}.
version
$Id: TempFileTextBody.java,v 1.3 2004/10/25 07:26:46 ntherning Exp $

Fields Summary
private static Log
log
private String
mimeCharset
private byte[]
tempFile
Constructors Summary
public MemoryTextBody(InputStream is)


         
        this(is, null);
    
public MemoryTextBody(InputStream is, String mimeCharset)

        
        this.mimeCharset = mimeCharset;
        
        TempPath tempPath = TempStorage.getInstance().getRootTempPath();
        
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        IOUtils.copy(is, out);
        out.close();
        tempFile = out.toByteArray();
    
Methods Summary
public java.io.ReadergetReader()

see
org.apache.james.mime4j.message.TextBody#getReader()

        String javaCharset = null;
        if (mimeCharset != null) {
            javaCharset = CharsetUtil.toJavaCharset(mimeCharset);
        }
        
        if (javaCharset == null) {
            javaCharset = "ISO-8859-1";
            
            if (log.isWarnEnabled()) {
                if (mimeCharset == null) {
                    log.warn("No MIME charset specified. Using " + javaCharset
                            + " instead.");
                } else {
                    log.warn("MIME charset '" + mimeCharset + "' has no "
                            + "corresponding Java charset. Using " + javaCharset
                            + " instead.");
                }
            }
        }
        /*
            if (log.isWarnEnabled()) {
                if (mimeCharset == null) {
                    log.warn("No MIME charset specified. Using the "
                           + "platform's default charset.");
                } else {
                    log.warn("MIME charset '" + mimeCharset + "' has no "
                            + "corresponding Java charset. Using the "
                            + "platform's default charset.");
                }
            }
            
            return new InputStreamReader(tempFile.getInputStream());
        }*/
        
        return new InputStreamReader(new ByteArrayInputStream(tempFile), javaCharset);
    
public voidwriteTo(java.io.OutputStream out)

see
org.apache.james.mime4j.message.Body#writeTo(java.io.OutputStream)

	IOUtils.copy(new ByteArrayInputStream(tempFile), out);