int (int line) { int count = 0; CharSequence docChars = myDocument.getCharsSequence(); for (int offset = myDocument.getLineStartOffset(line); offset < myDocument.getTextLength(); offset ++) { char c = docChars.charAt(offset); if (c != ' ' && c != '\t') break; count ++; } return count; }