TextUtils { public static String cutText(String input) { if (input == null) { return ""; } StringBuilder sb = new StringBuilder(); int len = input.length(); if (len > 0) { sb.append(input.charAt(0)); char lastCh = input.charAt(0); for (int i = 1; i < len; i++) { char ch = input.charAt(i); if (Character.isUpperCase(ch)) { char nextChar = i < len - 1 ? input.charAt(i + 1) : ' '; if (Character.isLowerCase(lastCh) && Character.isLetter(nextChar)) { sb.append(' '); } else if (Character.isUpperCase(lastCh) && Character.isLowerCase(nextChar)) { sb.append(' '); } } sb.append(ch); lastCh = ch; } } return sb.toString(); }  static String cutText(String input); static String[] cutTextAndSplit(String input);  }
@Test public void testCutText() { assertEquals("", TextUtils.cutText(null)); assertEquals("", TextUtils.cutText("")); String cutText = TextUtils.cutText("HelloWord!"); assertEquals("Hello Word!", cutText); cutText = TextUtils.cutText("ItIs𠀐𠀑"); assertEquals("It Is𠀐𠀑", cutText); }