class Test3 { public static void main(String[] args) { if (args.length != 1) { System.out.println("Usage: Test3 "); return; } try { // construct HTMLTokenizer for the URL or the file name passed in as the commandline argument HTMLTokenizer html = new HTMLTokenizer(args[0]); // first locate the landmark "eBay.com Bid History for" while (!html.nextTextMatch("eBay.com Bid History for")); // following code will achieve the same thing /* while (html.nextTextSubstring("History for") == null); */ // the next TEXT token contains the title of the item String s = html.nextTextToken(); if (s == null) { System.out.println("Can't find the title of the item"); return; } // get rid of the tail " (Item # " String title = s.substring(0, s.length() - 9); System.out.println("Title: " + title); } catch (Exception e) { System.err.println("Exception: " + e); } } }