import java.util.StringTokenizer; public class SearchString { public static void main( String args[ ] ) { int count = 0; SearchString searchString = new SearchString( args[0], args[1] ); System.out.println( "The string: " + args[0] + "
" ); System.out.println( "The query: " + args[1] + "

" ); StringTokenizer keyword = new StringTokenizer( args[1], " " ); while ( keyword.hasMoreTokens( ) ) count += searchString.keywordSearch( keyword.nextToken( ) ); System.out.println( "Number of keywords found: " + count + "" ); } private String str; private String query; public SearchString( String s, String q ) { str = s; query = q; } public int keywordSearch( String keyword ) { if ( str.toUpperCase( ).indexOf( keyword.toUpperCase( ) ) != -1 ) return( 1 ); else return( 0 ); } }