private int countLines(String input){
  int pos=0;
  int count=0;
  while (input.indexOf('\n',pos) > 0) {
    count++;
    pos=input.indexOf('\n',pos) + 1;
  }
  return (count);
}

private int countLines ( String input ) { int pos = 0 ; int count = 0 ; while ( input . indexOf ( '\n' , pos ) > 0 ) { count ++ ; pos = input . indexOf ( '\n' , pos ) + 1 ; } return ( count ) ; }
count lines of input string .
