I want to convert an ASCII string to a ByteBuffer and I came across these two approaches:
ByteBuffer.wrap(str.getBytes(StandardCharsets.US_ASCII));
and
StandardCharsets.US_ASCII.encode(str);
What is their difference (maybe in terms of performance too)? Would these produce the same result?