public static int count ( final String host , final String searchStr ) { int count = 0 ; for ( int startIndex = 0 ; startIndex < host . length ( ) ; startIndex ++ ) { int findLoc = host . indexOf ( searchStr , startIndex ) ; if ( findLoc == - 1 ) { break ; } else { count ++ ; startIndex = findLoc + searchStr . length ( ) - 1 ; } } return count ; }
count inner string in host string