How can I use Java to create a CSV file as a byte array from a String input - so not as a "java.io.File" ? Later on I need to send the file as payload on a REST API endpoint so saving on disk is not needed. This is what I have until now, is it any good ?
StringBuilder csv = new StringBuilder();
csv.append("column1;column2\r\n");
csv.append("cell1;cell2\r\n");
byte[] csvByteArray = csv.toString().getBytes();
I am using Java 17.
You can use something like this.