# How to stop RowFileInputReader after matching a specific line pattern (Text Header + Large Binary Tail)

**URL:** <https://forum.confluent.io/t/how-to-stop-rowfileinputreader-after-matching-a-specific-line-pattern-text-header-large-binary-tail/38260>\
**Category:** Kafka Connect\
**Created:** [24 February 2026 10:18 UTC](https://forum.confluent.io/t/how-to-stop-rowfileinputreader-after-matching-a-specific-line-pattern-text-header-large-binary-tail/38260 "2026-02-24T10:18:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![I-am-a-monster](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/i-am-a-monster/32/5214_2.png) [@I-am-a-monster](https://forum.confluent.io/u/I-am-a-monster)\
**Post date:** [24 February 2026 10:18 UTC](https://forum.confluent.io/t/how-to-stop-rowfileinputreader-after-matching-a-specific-line-pattern-text-header-large-binary-tail/38260/1 "2026-02-24T10:18:26Z")

</div>

Hi everyone,

I am using **kafka-connect-file-pulse** to process files that have a specific hybrid structure:

1. A multi-line text header
2. An empty line or custom characters line as a line separator
3. A large amount of binary data.

**My Goal** : I want to ingest the entire header as a single Kafka record and then immediately stop reading the file to avoid the overhead of processing the large binary tail.

**Possible Configuration:**  
I am thinking of using a **MultiRowFilter** to group the header and a **DropFilter** to discard the binary records,  
While the DropFilter prevents the binary data from being sent to Kafka, the RowFileInputReader still continues to read the entire file line-by-line which isn’t convenient in case of large data.

**So I would like to know :**

- Is there a way to signal the reader to stop/close the file stream as soon as a specific line with a special pattern is found ?
- Is there a way to read like a fixed number of lines and discard the rest ?

---

<div class="post-metadata">

**Author:** ![dtroiano](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/dtroiano/32/1961_2.png) [@dtroiano](https://forum.confluent.io/u/dtroiano)\
**Post date:** [24 February 2026 14:43 UTC](https://forum.confluent.io/t/how-to-stop-rowfileinputreader-after-matching-a-specific-line-pattern-text-header-large-binary-tail/38260/2 "2026-02-24T14:43:35Z")

</div>

I’m not finding a way to short circuit. It doesn’t look to be too complicated to implement this feature though. It’s pretty similar to `read.max.wait.ms`, except you would stop iterating on a pattern match rather than time elapsed. See [here](https://github.com/streamthoughts/kafka-connect-file-pulse/blob/eabcb44e73a8ea167be0ef76d417a723b9717c16/connect-file-pulse-filesystems/filepulse-commons-fs/src/main/java/io/streamthoughts/kafka/connect/filepulse/fs/reader/text/RowFileInputIterator.java#L159). Basically that change plus some config plumbing = win? See if you get similar advice on [this](https://github.com/streamthoughts/kafka-connect-file-pulse/issues/746) GH issue and, if you’re interested, you might submit a PR to contribute this feature.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)\
**Post date:** [26 March 2026 14:43 UTC](https://forum.confluent.io/t/how-to-stop-rowfileinputreader-after-matching-a-specific-line-pattern-text-header-large-binary-tail/38260/3 "2026-03-26T14:43:56Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
