public static int getLineNumber ( String text , int posChar ) { int len = Math . min ( posChar , text . length ( ) ) ; int result = 1 ; for ( int i = 0 ; i < len ; i ++ ) { if ( text . charAt ( i ) == ' ' ) result ++ ; } return result ; }
returns the line number of the given char in the text