8262161: Refactor manual I/O stream copying in java.desktop to use new convenience APIs

Reviewed-by: serb, prr
This commit is contained in:
Andrey Turbanov 2021-03-09 01:36:50 +00:00 committed by Sergey Bylokhov
parent 4e9476071d
commit 39b1113838
11 changed files with 32 additions and 131 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 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
@ -1978,16 +1978,7 @@ search:
protected static byte[] inputStreamToByteArray(InputStream str)
throws IOException
{
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
int len = 0;
byte[] buf = new byte[8192];
while ((len = str.read(buf)) != -1) {
baos.write(buf, 0, len);
}
return baos.toByteArray();
}
return str.readAllBytes();
}
/**