Read byte array into base64 encoded image
<p>I'm trying to read an image into a ByteArrayOutputStream and then encode the array into Base64 for sending as part of a json to my API.  I'm wanting to avoid saving it anywhere and just read it, encode, and send.  Unfortunately, when I use the ByteArrayOutputStream.toByteArray() as a parameter in Base64.getEncoder.encodeToString() method it returns a String that contains extra break characters '\' in the String as compared to a successful test reading from a File into Base64.  </p>

<p>Is it possible to read directly from the byte array into base 64?  Or will I have to translate into an image then to base 64?</p>

<p>Any help is appreciated.</p>