Same as the known length example, but insert the length into regex:
int length = 5; String[] parts = str.split("(?<=\\G.{" + length + "})");