public static String expandLine ( CharSequence self , int tabStop ) { String s = self . toString ( ) ; int index ; while ( ( index = s . indexOf ( ' ' ) ) != - 1 ) { StringBuilder builder = new StringBuilder ( s ) ; int count = tabStop - index % tabStop ; builder . deleteCharAt ( index ) ; for ( int i = 0 ; i < count ; i ++ ) builder . insert ( index , " " ) ; s = builder . toString ( ) ; } return s ; }
Expands all tabs into spaces . Assumes the CharSequence represents a single line of text .