NiFi 读取Processor中的FlowFile

在Processor的onTrigger方法中,可以从ProcessSession参数中获取FlowFile中的内容,参考网上的一些写法,如
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>

猜你喜欢

转载自ouanui.iteye.com/blog/2358634