I have to a class that generates an Excel file, class takes an output stream, intended for a FileOutputWriter.
However I need to upload the file to S3 later, so saving it to a file would be an unnecessary step.
To upload a file to S3 do I need it as an input stream. 
I have therefore been looking for a way to convert an output stream to an input stream or transfer the data to an input stream.
I have tried PipeOutputStream, but xlsFile.write(outstr); just blocks forever when using a PipedOutputStream, using a FileOutputStream will it work fine and write the file.
PipedInputStream inputStream = new PipedInputStream();
try (OutputStream outstr = new PipedOutputStream(inputStream)) {
    xlsFile.write(outstr);
    outstr.flush();
    return inputStream;
}
 
     
    