Skip to content

Commit

Permalink
Slightly more efficient conversion to string
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher committed Aug 4, 2022
1 parent 3d6706f commit 4f74122
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import lombok.extern.slf4j.Slf4j;

Expand All @@ -30,7 +31,7 @@ public static String inputStreamToString(final InputStream is, final Charset cha
while ((length = is.read(buffer)) != -1) {
outputStream.write(buffer, 0, length);
}
return new String(charset.decode(ByteBuffer.wrap(outputStream.toByteArray())).array());
return outputStream.toString(charset.name());
}

public static String resourceToString(final String resource, final Charset charset, final ClassLoader cl)
Expand Down

0 comments on commit 4f74122

Please sign in to comment.