Skip to content

Commit

Permalink
Replace ByteArrayOutputStream#toString() with alternative.
Browse files Browse the repository at this point in the history
  • Loading branch information
LossyDragon committed Dec 28, 2024
1 parent 7290ebe commit 44a0a91
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ public String readNullTermString(Charset charset) throws IOException {

byte[] bytes = buffer.toByteArray();
position += bytes.length;

return new String(bytes, charset);
}

@SuppressWarnings("StringOperationCanBeSimplified")
private String readNullTermUtf8String() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int b;
Expand All @@ -146,7 +148,8 @@ private String readNullTermUtf8String() throws IOException {

position++; // Increment for the null terminator

return baos.toString(StandardCharsets.UTF_8);
// Suppressed. Fixes NoSuchMethodError in Java 11 on the Google Pixel 3 XL (Android 12)
return new String(baos.toByteArray(), StandardCharsets.UTF_8);
}

public int getPosition() {
Expand Down

0 comments on commit 44a0a91

Please sign in to comment.