Index: modules/awt/src/main/java/common/org/apache/harmony/awt/text/TextUtils.java =================================================================== --- modules/awt/src/main/java/common/org/apache/harmony/awt/text/TextUtils.java (revision 487517) +++ modules/awt/src/main/java/common/org/apache/harmony/awt/text/TextUtils.java (working copy) @@ -132,7 +132,7 @@ BreakIterator bi = BreakIterator.getWordInstance(); int length = doc.getLength(); - if (pos < 0 || pos > length) { + if (pos < 0 || pos >= length) { // awt.2F=No more words throwException(Messages.getString("awt.2F"), pos); //$NON-NLS-1$ } @@ -143,13 +143,12 @@ int iteratorNextWord = bi.following(pos); while (iteratorNextWord < length - && ((content.charAt(iteratorNextWord) == ' ' - || content.charAt(iteratorNextWord) == '\n') - || content.charAt(iteratorNextWord) == '\t')) { - iteratorNextWord = bi.following(iteratorNextWord); + && Character.isWhitespace(content.charAt(iteratorNextWord))) { + iteratorNextWord = bi.following(iteratorNextWord); } if (iteratorNextWord == length) { - iteratorNextWord = 0; + // awt.2F=No more words + throwException(Messages.getString("awt.2F"), pos); //$NON-NLS-1$ } return iteratorNextWord; }