8273528: Avoid ByteArrayOutputStream.toByteArray when converting stream to String
Reviewed-by: bpb, xuelei, serb, aivanov
This commit is contained in:
parent
54dee132d1
commit
2e321dc782
@ -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
|
||||
@ -261,7 +261,7 @@ public class BitArray {
|
||||
out.write(get(i) ? '1' : '0');
|
||||
}
|
||||
|
||||
return new String(out.toByteArray());
|
||||
return out.toString();
|
||||
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ public class PNGImageReader extends ImageReader {
|
||||
if (b != 0) {
|
||||
throw new IIOException("Found non null terminated string");
|
||||
}
|
||||
return new String(baos.toByteArray(), charset);
|
||||
return baos.toString(charset);
|
||||
}
|
||||
|
||||
private void readHeader() throws IIOException {
|
||||
|
@ -134,7 +134,7 @@ public final class DebugSettings {
|
||||
String value = props.getProperty(key, "");
|
||||
pout.println(key + " = " + value);
|
||||
}
|
||||
return new String(bout.toByteArray());
|
||||
return bout.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -945,10 +945,9 @@ search:
|
||||
}
|
||||
|
||||
if (DataFlavorUtil.isFlavorCharsetTextType(flavor) && isTextFormat(format)) {
|
||||
byte[] bytes = bos.toByteArray();
|
||||
String sourceEncoding = DataFlavorUtil.getTextCharset(flavor);
|
||||
return translateTransferableString(
|
||||
new String(bytes, sourceEncoding),
|
||||
bos.toString(sourceEncoding),
|
||||
format);
|
||||
}
|
||||
theByteArray = bos.toByteArray();
|
||||
|
Loading…
x
Reference in New Issue
Block a user