title: How to write into an output stream with content is csv using opencsv?
body: <pre><code>@Value(&quot;classpath:tpls/Non-PnL_Template_Export_Order_Cross_Checking.csv&quot;)
  private org.springframework.core.io.Resource exportFileOrderTpl;
  </code></pre>
  <p>I create an output stream of a CSVWriter</p>
  <pre><code>InputStream inputStream = exportFileOrderTpl.getInputStream();
  
  String outputFileName = &quot;file.csv&quot;
  
  var fileOutputStream = new FileOutputStream(outputFileName);
  
  IOUtils.copy(inputStream, fileOutputStream);
  
  var outputStreamWriter = new OutputStreamWriter(fileOutputStream,StandardCharsets.UTF_8);
  
  var writer = new CSVWriter(outputStreamWriter)
  
  String [] rows = {&quot;1&quot;,&quot;2&quot;,&quot;3&quot;}
  writer.writeNext(rows);
  
  var outputStream = new ByteArrayOutputStream();
  outputStream.writeTo(fileOutputStream);
  </code></pre>
  <p>But my <code>outputStream</code> is empty. How to fix it!. Thank you</p>