在Processor的onTrigger方法中,可以从ProcessSession参数中获取FlowFile中的内容,参考网上的一些写法,如
读出来的内容总是空的。
想要读取到内容,可以采取一下方法
不过想要引入apache的common-io包
session.read(flowFile, new InputStreamCallback() {
@Override
public void process(final InputStream in) throws IOException {
final InputStream bin = new BufferedInputStream(in);
System.out.println(bin);
}
});读出来的内容总是空的。
想要读取到内容,可以采取一下方法
System.out.println(IOUtils.toString(in,Charset.defaultCharset()));不过想要引入apache的common-io包
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
本文介绍在NiFi中如何正确从FlowFile读取内容。通过使用IOUtils工具类,能够成功打印出FlowFile的内容。然而这需要引入Apache Commons IO库。
799

被折叠的 条评论
为什么被折叠?



