How to convert java.io.StringWriter
to byte[]
array?
Using OpenCSV
i get StringWriter
sw
object and this sw
object I want to convert into byte[]
array.
Arrays. fill(). This method assigns the required byte value to the byte array in Java.
You can simply iterate the byte array and print the byte using System. out. println() method.
The byteValue() method of Integer class of java. lang package converts the given Integer into a byte after a narrowing primitive conversion and returns it (value of integer object as a byte).
You can do
byte[] bytes = stringWriter.toString().getBytes("UTF-8");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With