OpenCSV Avoid using FileWriter and return InputStream
<p>I am using OpenCsv and the <code>new CSVWriter()</code> method takes a Writer as an argument.</p>

<p>What I am trying to achieve is that to avoid writing to the file system and instead return an <code>InputStream</code>. I am not sure how to go about this. Not very familiar with <code>Streams</code> also I am using <code>JAVA 7</code>.</p>

<p>Is it possible that I could make the writeValues method return an InputStream and avoid writing the output on file system.</p>

<p>This is my working implementation:</p>

<pre><code>private static void writeValues(String[][] cellValues) throws IOException {

    CSVWriter writer = new CSVWriter(new FileWriter("/tmp/myfile.csv"));
    for(String[] row : cellValues) { 
        writer.writeNext(row);
    }
    writer.close();
}
</code></pre>

<p>This is what I want to achieve.
How to Convert the above method to avoid using a FileWriter.</p>

<pre><code>private static InputStream writeValues(String[][] cellValues) throws IOException {

    InputStream inputStream = ?;

    CSVWriter writer = new CSVWriter(?);
    for(String[] row : cellValues) { 
        writer.writeNext(row);
    }
    writer.close();

    return inputStream;
}
</code></pre>