I want to make an http request using a stream (because I think there is no other way) but I can only send a byte array using streams. I want to send a file by encoding it in Base64 then sending the encoded base64 code so I can decode it later. So far I can easily encode it using
byte[] contentBytes = loadFile(txt);
byte[] encoded = Base64.getEncoder().encode(contentBytes);
String encodedContentString = new String(encoded, StandardCharsets.US_ASCII);
But as one can see I get a string. Can I turn it into a byte array not or can I encode the file into a byte array directly? Maybe I used it wrong but I am pretty sure I can't just use encodedContentStrin.getBytes()