-
Enhancement
-
Resolution: Fixed
-
P5
-
None
-
b08
There is method sun.security.provider.certpath.X509CertPath#readAllBytes which does reading all bytes from an InputStream
private static byte[] readAllBytes(InputStream is) throws IOException {
byte[] buffer = new byte[8192];
ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
int n;
while ((n = is.read(buffer)) != -1) {
baos.write(buffer, 0, n);
}
return baos.toByteArray();
}
Since Java 9 we have a handy method java.io.InputStream#readAllBytes which could be used instead.
private static byte[] readAllBytes(InputStream is) throws IOException {
byte[] buffer = new byte[8192];
ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
int n;
while ((n = is.read(buffer)) != -1) {
baos.write(buffer, 0, n);
}
return baos.toByteArray();
}
Since Java 9 we have a handy method java.io.InputStream#readAllBytes which could be used instead.