in src/main/java/software/amazon/payloadoffloading/Util.java [16:32]
public static long getStringSizeInBytes(String str) {
CountingOutputStream counterOutputStream = new CountingOutputStream();
try {
Writer writer = new OutputStreamWriter(counterOutputStream, StandardCharsets.UTF_8);
writer.write(str);
writer.flush();
writer.close();
} catch (IOException e) {
String errorMessage = "Failed to calculate the size of payload.";
LOG.error(errorMessage, e);
throw SdkClientException.create(errorMessage, e);
}
return counterOutputStream.getTotalSize();
}