import java.nio.charset.StandardCharsets; String rawString = "こんにちは"; byte[] bytes = rawString.getBytes(StandardCharsets.UTF_8);