How to get the substring that contains the first N unicode characters in Java
There's not a method that does it in one call, but offsetByCodePoints()
will help you do this.
static String substring(String str, int idx, int len) {
return str.substring(idx, str.offsetByCodePoints(idx, len));
}