Write csv file from byte[]
<p>I am getting a file in <strong><code>byte[]</code></strong> which have comma separated values in quotes, I want to save it as CSV by using OpenCSV. I am <a href="https://stackoverflow.com/a/10452463/1860468">using this</a> to save it in CSV format.</p>

<p>Following is my code to convert byte[] to array and then store it in file</p>

<pre><code>byte[] bytes = myByteStream.getFile();

String decoded = new String(bytes, "UTF-8");            
//String lines[] = decoded.split("\\r?\\n");


FileOutputStream fos = new FileOutputStream("/home/myPC/Desktop/test.csv"); 
OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
CSVWriter writer = new CSVWriter(osw);
String[] row = {decoded};

writer.writeNext(row);
writer.close();
osw.close();
</code></pre>

<p>But this above code puts extra quotes around and also merge all lines in one line.</p>

<p>Any help on how to do this properly ?</p>