MemoryTextBodypublic class MemoryTextBody 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 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.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(new ByteArrayInputStream(tempFile), javaCharset);
| public void | writeTo(java.io.OutputStream out)
IOUtils.copy(new ByteArrayInputStream(tempFile), out);
|
|