title: Mule 4 : how to generate a Text file from an Array
body: <p>I have to generate a text file from an Array. To do this, I am taking the following approach :</p>
  <ol>
  <li>Creating a Java Array from the json payload using Dataweave map method</li>
  <li>Using a For each component to iterate over the Array</li>
  <li>Using a File:Write Component inside the foreach and writing the element by converting them to String as follows : <code>write(payload,&quot;application/java&quot;)</code> and setting the File Write Mode to Append</li>
  </ol>
  <p>Is there any better way to achieve this?</p>
  <p>Example of Array :</p>
  <pre><code>[[&quot;Amam&quot;,&quot;ssss&quot;,&quot;Bibek&quot;,&quot;Raghu&quot;,&quot;Rajeev&quot;],[&quot;Apple&quot;,&quot;Banana&quot;,&quot;Orange&quot;,&quot;Pineapple&quot;,&quot;Pears&quot;]] 
  </code></pre>
  <p>And in text file I want the output to be as :</p>
  <pre><code>Amam ssss Bibek Raghu Rajeev 
  Apple Banana Orange Pineapple Pears 
  </code></pre>