title: How to create a CSV file with linebreaks and quotations marks?
body: <p>In my Java application, I'm going to write a CSV file with various columns. Some of these columns contain source code and therefore linebreaks, quotation marks and other special characters.</p>
  
  <p>I'm running into the problem that this destroys the structure of my CSV file. I tried to mitigate this problem by using the method escapeCsv from the StringEscapeUtils class like that:</p>
  
  <pre><code>StringEscapeUtils.escapeCsv(getId().toString()) + ", " + StringEscapeUtils.escapeCsv(dateFormat.format(getTimestamp()));
  </code></pre>
  
  <p>But still, the linebreaks and quotation marks in the source code destroys the structure of my CSV file. What else can I do?</p>