title: Filter Kafka Streams
body: <p>I have been checking Kafka streams. I have been testing the below code for Kafka streams</p>
  
  <p>Producer topic: (this is the first producer topic - which sends the below json data)</p>
  
  <pre><code>KafkaProducer&lt;String, String&gt; producer = new KafkaProducer&lt;&gt;(
                      properties);
  
      producer.send(new ProducerRecord&lt;String,String&gt;(topic, jsonobject.toString()));
                    producer.close();
  </code></pre>
  
  <p>JSON - Producer from topic:</p>
  
  <pre><code>{"UserID":"1","Address”:”XXX”,”AccountNo":"234234","MemberName”:”Stella”,”AccountType":"Savings"}
  </code></pre>
  
  <p>Stream Topic code: (this is the second Streaming code and topic)</p>
  
  <pre><code>builder.&lt;String,String&gt;stream(topic)
             .filter(new Predicate &lt;String, String&gt;() {
                 @Override
  
              public boolean test(String key, String value) {
  
                     // put you processor logic here
                     System.out.println("value : " + value);
  
                     return value.substring(0).equals(“1”);
                 }
              }) 
             .to(streamouttopic);
  
           final KafkaStreams streams = new KafkaStreams(builder, props);
           final CountDownLatch latch = new CountDownLatch(1);
  
              // attach shutdown handler to catch control-c
              Runtime.getRuntime().addShutdownHook(new Thread("streams-shutdown-hook") {
                  @Override
                  public void run() {
                      streams.close();
                      latch.countDown();
                  }
              });
  
              try {
                  streams.start();
                  latch.await();
              } catch (Throwable e) {
                  System.exit(1);
              }
              System.exit(0);
  </code></pre>
  
  <p>I want to filer if UserID value is “1”, then send that data to destination streaming topic.</p>
  
  <p>When I use “.filter” and print System.out.println("value : " + value);, it throws the below error when executing.</p>
  
  <pre><code>Exception in thread "SampleStreamProducer-a6bb543e-bb92-48d0-8d9f-225046722d81-StreamThread-1" java.lang.ClassCastException: [B cannot be cast to java.lang.String
  </code></pre>
  
  <p>If i don’t use “.filter” and use simple code like this, <code>builder.stream(topic).to(streamouttopic);</code>  , it is working fine, but without filtering. But, I need to use that filter. </p>
  
  <p>Can someone guide me to fix it?</p>