8080272: Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy

Reviewed-by: mcimadamore, alanb
This commit is contained in:
Andrey Turbanov 2021-03-16 10:10:05 +00:00 committed by Julia Boes
parent a31a23d5e7
commit 68deb24b38
7 changed files with 27 additions and 102 deletions

View file

@ -2481,15 +2481,9 @@ public final class Main {
// otherwise, keytool -gencrl | keytool -printcrl
// might not work properly, since -gencrl is slow
// and there's no data in the pipe at the beginning.
ByteArrayOutputStream bout = new ByteArrayOutputStream();
byte[] b = new byte[4096];
while (true) {
int len = in.read(b);
if (len < 0) break;
bout.write(b, 0, len);
}
byte[] bytes = in.readAllBytes();
return CertificateFactory.getInstance("X509").generateCRLs(
new ByteArrayInputStream(bout.toByteArray()));
new ByteArrayInputStream(bytes));
} finally {
if (in != System.in) {
in.close();