mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8080272: Refactor I/O stream copying to use InputStream.transferTo/readAllBytes and Files.copy
Reviewed-by: mcimadamore, alanb
This commit is contained in:
parent
a31a23d5e7
commit
68deb24b38
7 changed files with 27 additions and 102 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -90,7 +90,7 @@ public class JarInputStream extends ZipInputStream {
|
|||
{
|
||||
if (e != null && JarFile.MANIFEST_NAME.equalsIgnoreCase(e.getName())) {
|
||||
man = new Manifest();
|
||||
byte bytes[] = getBytes(new BufferedInputStream(this));
|
||||
byte[] bytes = readAllBytes();
|
||||
man.read(new ByteArrayInputStream(bytes));
|
||||
closeEntry();
|
||||
if (doVerify) {
|
||||
|
@ -102,18 +102,6 @@ public class JarInputStream extends ZipInputStream {
|
|||
return e;
|
||||
}
|
||||
|
||||
private byte[] getBytes(InputStream is)
|
||||
throws IOException
|
||||
{
|
||||
byte[] buffer = new byte[8192];
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
|
||||
int n;
|
||||
while ((n = is.read(buffer, 0, buffer.length)) != -1) {
|
||||
baos.write(buffer, 0, n);
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@code Manifest} for this JAR file, or
|
||||
* {@code null} if none.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue