I want to convert a org.apache.poi.ss.usermodel.Workbook to a org.springframework.core.io.Resource. Currently, I do this like so
public Resource toResource(Workbook workbook) {
var outputStream = new ByteArrayOutputStream()
workbook.write(outputStream);
return new ByteArrayResource(outputStream.toByteArray());
}
It seems like there ought to be a more straightforward way, that doesn't require the intermediate ByteArrayOutputStream. Can this code be simplified?