¿Cómo convertir rápidamente OutputStream a InputStream?
Hoy ayudé a mis colegas a resolver el problema de convertir OutputStream a InputStream en Java. Permítanme registrarlo:
no digan tonterías, solo cargue el código directamente. El principio es lo que pienso:
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] bytes = outputStream.toByteArray();
ByteBuffer buffer = ByteBuffer.wrap(bytes);
InputStream inputStream = new ByteArrayInputStream(buffer.array());