<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question How can I send FlowFile content to String in Java? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-send-FlowFile-content-to-String-in-Java/m-p/185971#M64910</link>
    <description>&lt;P&gt;I'm new in NiFi and i'm trying to make a simple processor in Java. I need to send flowFile content to String and compare with Processor Property (which is actually in string). Is any method in NiFi packages for it?&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jul 2017 13:22:36 GMT</pubDate>
    <dc:creator>marceli195s</dc:creator>
    <dc:date>2017-07-14T13:22:36Z</dc:date>
    <item>
      <title>How can I send FlowFile content to String in Java?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-send-FlowFile-content-to-String-in-Java/m-p/185971#M64910</link>
      <description>&lt;P&gt;I'm new in NiFi and i'm trying to make a simple processor in Java. I need to send flowFile content to String and compare with Processor Property (which is actually in string). Is any method in NiFi packages for it?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2017 13:22:36 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-send-FlowFile-content-to-String-in-Java/m-p/185971#M64910</guid>
      <dc:creator>marceli195s</dc:creator>
      <dc:date>2017-07-14T13:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I send FlowFile content to String in Java?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-send-FlowFile-content-to-String-in-Java/m-p/185972#M64911</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/23201/marceli195s.html" nodeid="23201"&gt;@Marceli Stawicki&lt;/A&gt; There are a few ways to do this. The most common way is to read the FlowFile contents in a ProcessSession#read and assign the contents to an AtomicReference. For example:&lt;/P&gt;&lt;PRE&gt;final AtomicReference&amp;lt;String&amp;gt; contentsRef = new AtomicReference&amp;lt;&amp;gt;(null);

session.read(flowFile, new InputStreamCallback() {
    @Override
    public void process(final InputStream in) throws IOException {
        final String contents = IOUtils.toString(in, "UTF-8");
        contentsRef.set(contents);
    }
})

final String contents = contentsRef.get();
&lt;/PRE&gt;&lt;P&gt;Another approach is to use ProcessSession#exportTo:&lt;/P&gt;&lt;PRE&gt;final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
session.exportTo(flowFile, bytes);
final String contents = bytes.toString();
&lt;/PRE&gt;&lt;P&gt;From there you should be able to compare contents to the value of the property.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 02:41:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-send-FlowFile-content-to-String-in-Java/m-p/185972#M64911</guid>
      <dc:creator>jfrazee</dc:creator>
      <dc:date>2017-07-15T02:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: How can I send FlowFile content to String in Java?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-send-FlowFile-content-to-String-in-Java/m-p/185973#M64912</link>
      <description>&lt;P&gt;Thanks, it worked!&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 18:03:11 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/How-can-I-send-FlowFile-content-to-String-in-Java/m-p/185973#M64912</guid>
      <dc:creator>marceli195s</dc:creator>
      <dc:date>2017-07-15T18:03:11Z</dc:date>
    </item>
  </channel>
</rss>

