I am currently writing a lot of text to a file using a BufferedWriter. I pass the BufferedWriter object around to various functions in my code. I now need to use a stream object in my functions in order to use the Base64OutputStream class in one place. I'm unsure how to change all of my code without needing to convert strings to bytes for every .write() call and also avoid calling helper functions like IOUtils.write() since that sounds like it would impact performance.
Shall I just give in and call the IOUtils.write() function for the string writes? The code is certainly ugly compared to a clean call to a stream or writer write() function.
Could I create both a stream object and a writer object and pass both around, switching between them as needed (which sounds like it would just crash or cause corruption)?
Java is a second language for me so I don't know off the top of my head all of the possible classes and functions available to me. I would like the code to be as readable and maintainable as possible.