title: Mule 4 Pipe Delimited text file to JSON
body: <p>I need to convert Pipe Delimited text file to JSON in Mule 4. I tried with below code.</p>
  
  <pre><code>`&lt;file:listener doc:name="Fetch Input from Geometry SFTP" doc:id="1151a602-6748-43b7-b491-2caedf6f7010" directory="C:\Vijay\My Projects\AM-Mexico\US\AIM-65\Input" autoDelete="true" outputMimeType="text/csv; separator=|" recursive="false"&gt;
              &lt;non-repeatable-stream /&gt;
              &lt;scheduling-strategy &gt;
                  &lt;fixed-frequency frequency="10" timeUnit="SECONDS"/&gt;
              &lt;/scheduling-strategy&gt;
          &lt;/file:listener&gt;
          &lt;ee:transform doc:name="Transform Message" doc:id="79dcddf9-34a0-4005-88b4-3a395544be8c" &gt;
              &lt;ee:message &gt;
                  &lt;ee:set-payload &gt;&lt;![CDATA[%dw 2.0
  output application/json
  input payload text/csv
  ---
  payload]]&gt;&lt;/ee:set-payload&gt;
              &lt;/ee:message&gt;
          &lt;/ee:transform&gt;`
  </code></pre>
  
  <p>If I try to execute the code i am getting exception as below.</p>
  
  <pre><code>Message               : "Internal execution exception while executing the script this is most probably a bug.
  Caused by:
  java.nio.channels.ClosedChannelException
      at sun.nio.ch.FileChannelImpl.ensureOpen(FileChannelImpl.java:110)
      at sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:147)
      at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:65)
      at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:109)
      at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:103)
      at java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
      at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
      at $java.io.InputStream$$FastClassByCGLIB$$31b19c4e.invoke(&lt;generated&gt;)
      at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
      at org.mule.extension.file.common.api.stream.AbstractFileInputStream.lambda$createLazyStream$0(AbstractFileInputStream.java:41)
      at $java.io.InputStream$$EnhancerByCGLIB$$55e4687e.read(&lt;generated&gt;)
      at org.apache.commons.io.input.ProxyInputStream.read(ProxyInputStream.java:98)
      at org.mule.weave.v2.io.DefaultSeekableStream.readUntil(SeekableStream.scala:193)
      at org.mule.weave.v2.io.DefaultSeekableStream.delegate$lzycompute(SeekableStream.scala:202)
      at org.mule.weave.v2.io.DefaultSeekableStream.delegate(SeekableStream.scala:201)
      at org.mule.weave.v2.io.DefaultSeekableStream.seek(SeekableStream.scala:234)
      at org.mule.weave.v2.io.SeekableStream.resetStream(SeekableStream.scala:17)
      at org.mule.weave.v2.io.SeekableStream.resetStream$(SeekableStream.scala:16)
      at org.mule.weave.v2.io.DefaultSeekableStream.resetStream(SeekableStream.scala:186)
      at org.mule.weave.v2.model.values.BinaryValue$.getBytesFromSeekableStream(BinaryValue.scala:84)
      at org.mule.weave.v2.model.values.BinaryValue$.getBytes(BinaryValue.scala:68)
      at org.mule.weave.v2.model.values.BinaryValue.equals(BinaryValue.scala:26)
      at org.mule.weave.v2.model.values.BinaryValue.equals$(BinaryValue.scala:25)
      at org.mule.weave.v2.module.pojo.reader.JavaBinaryValue.equals(JavaBinaryValue.scala:11)
      at org.mule.weave.v2.model.values.wrappers.DelegateValue.equals(DelegateValue.scala:38)
      at org.mule.weave.v2.model.values.wrappers.DelegateValue.equals$(DelegateValue.scala:37)
      at org.mule.weave.v2.model.values.wrappers.LazyValue.equals(DelegateValue.scala:65)
      at org.mule.weave.v2.model.types.Type.$anonfun$acceptsSchema$2(Type.scala:203)
      at org.mule.weave.v2.model.types.Type.$anonfun$acceptsSchema$2$adapted(Type.scala:198)
  </code></pre>
  
  <p>any help on this would be higly appreciated.</p>