Output a byte stream to stdout
base64, encryption, java, stdout
Solution
PrintStream (class of stdout) has a write method which could be called to write a byte[] to stdout.
Problem
I have following function, which decrypts a base64 file and writes it to a txt file. However, instead of it writing to a text file, I want it to output to stdout. Can you please suggest how we could do that ``` CipherOutputStream cos = new CipherOutputStream(os, cipher); doCopy(is, cos); } public static void doCopy(InputStream is, OutputStream os) throws IOException { byte[] bytes = new byte[64]; int numBytes; while ((numBytes = is.read(bytes)) != -1) { os.write(bytes, 0, numBytes); } ``` So instead of os.write writing the stream to a txt file, it should write it to stdout.