将InputStream的内容写入RichTextItem并附加到Java中的Notes文档 [英] Write contents of InputStream to a RichTextItem and attach to a Notes document in Java
问题描述
我能够将文件附加到作为InputStream
收到的多米诺骨牌文档的RichTextItem
上.下面是代码片段:
I am able to attach a file to RichTextItem
of a domino document that I receive as an InputStream
. Below is the code snippet:
attachDocument(InputStream is){
.....
File attFile = saveInputStr(is);
Document attdoc = testdb.createDocument();
attDoc.replaceItemValue("Form", "formAttachment");
RichTextItem rti = (RichTextItem) attDoc.getFirstItem("attachment");
rti.embedObject(EmbeddedObject.EMBED_ATTACHMENT, "", attFile .getPath(), attFile .getName());
.....
}
这很好.但是,如果我不想将文件写入磁盘,就像我将其保存到上述片段中的File
即attFile
那样,该怎么办.有没有一种方法可以将InputStream
的内容写入文件(可能正在使用某些注释文档)并附加而不保存到磁盘.
This works fine. But what if I don't want to write the file to disk, like I save it to a File
i.e. attFile
in the above snippet. Is there a way that to write the contents of InputStream
to a file (may be using some notes document) and attach it with out saving to disk.
推荐答案
我实际上找到了解决问题的方法.也许对某人会有帮助
I actually found solution for my question. Maybe it will be helpful for someone
attachDocument(InputStream is){
.....
//File attFile = saveInputStr(is);
Document attdoc = testdb.createDocument();
attDoc.replaceItemValue("Form", "formAttachment");
//RichTextItem rti = (RichTextItem) attDoc.getFirstItem("attachment");
//rti.embedObject(EmbeddedObject.EMBED_ATTACHMENT, "", attFile .getPath(), attFile .getName());
attDoc.getFirstItem("attachment");
Stream stream = DominoUtils.getCurrentSession().createStream();
stream.write(IOUtils.toByteArray(is));
MIMEEntity me = attDoc.createMIMEEntity("attachment");
me.setContentFromBytes(stream, "application/pdf", MIMEEntity.ENC_IDENTITY_8BIT);
is.close();
attdoc.save();
.....
}
这篇关于将InputStream的内容写入RichTextItem并附加到Java中的Notes文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!