I am writing a csv file in a very old java application so i can not use all the new Java 8 streams.
Writer writer = new OutputStreamWriter(new FileOutputStream("file.csv"));
writer.append("data,");
writer.append("data,");
...
Then I need to transform the writer object into a ByteArrayInputStream. How can i do it ?
Thanks in advance. Best regards.
Short answer: you can't.
A
ByteArrayInputStreamis just not assignable from aOutputStreamWriter.Since you're probably after write, you can just read the file back to a
byte[]and then construct aByteArrayInputStreamwith it: