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

TempFileTextBody

public class TempFileTextBody 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 org.apache.james.mime4j.util.TempFile
tempFile
Constructors Summary
public TempFileTextBody(InputStream is)


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

        
        this.mimeCharset = mimeCharset;
        
        TempPath tempPath = TempStorage.getInstance().getRootTempPath();
        tempFile = tempPath.createTempFile("attachment", ".txt");
        
        OutputStream out = tempFile.getOutputStream();
        IOUtils.copy(is, out);
        out.close();
    
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(tempFile.getInputStream(), javaCharset);
    
public voidwriteTo(java.io.OutputStream out)

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

	IOUtils.copy(tempFile.getInputStream(), out);