TempFileTextBodypublic class TempFileTextBody extends AbstractBody implements TextBodyText body backed by a {@link org.apache.james.mime4j.util.TempFile}. |
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.Reader | 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 void | writeTo(java.io.OutputStream out)
IOUtils.copy(tempFile.getInputStream(), out);
|
|