import java.util.*; import java.net.*; import java.io.*; class s02 { public static void main(String[] args) { try { URL yahoo = new URL("http://www.yahoo.com/"); DataInputStream dis = new DataInputStream(yahoo.openStream()); String inputLine; String sisu=""; while ((inputLine = dis.readLine()) != null) { System.out.println(inputLine); sisu+=inputLine; } dis.close(); boolean nextIsTag = false ; for ( StringTokenizer tags = new StringTokenizer(sisu, "<>", true ); tags.hasMoreTokens(); ) { String tag = tags.nextToken(); if ( tag.equals( "<" ) ) { nextIsTag = true ; continue ; } if ( nextIsTag ) { for ( StringTokenizer params = new StringTokenizer( tag, "\t\n\r\"= " ); params.hasMoreTokens(); ) { String param = params.nextToken().toLowerCase(); if ( param.equals( "href" ) && params.hasMoreTokens() ) {System.out.println(params.nextToken());} } nextIsTag = false ; }} } catch (MalformedURLException me) { System.out.println("MalformedURLException: " + me); } catch (IOException ioe) { System.out.println("IOException: " + ioe); } } }