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.
PrintStream (class of stdout) has a write method which could be called to write a byte[] to stdout.
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