void () { if (myRecordText.length() == 0) return; int endIndex = myRecordText.length() - 1; if (myRecordText.charAt(endIndex) != ' ') return; while (endIndex > 0 && (myRecordText.charAt(endIndex - 1) == ' ' || myRecordText.charAt(endIndex - 1) == '\n')) { endIndex--; } myRecordText.setLength(endIndex); }