import java.util.*; import java.net.*; import java.io.*; class s03 { public static void main(String[] args) { String masin="http://www.yahoo.com"; String aadress[]=new String[1000]; String puhas[]=new String[1000]; String kataloog,abi, viimane; int aarv=0, parv=0, i; int reas=0; 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() ) {aadress[aarv++]=params.nextToken();} } nextIsTag = false ; }} } catch (MalformedURLException me) { System.out.println("MalformedURLException: " + me); } catch (IOException ioe) { System.out.println("IOException: " + ioe); } for(i=0; i-1) aadress[i]=aadress[i].substring(0,aadress[i].indexOf("?")); System.out.println(aadress[i]+" uus");} while(reas==0) { int il; reas=1; for(il=0; il0){ reas=0; abi=aadress[il]; aadress[il]=aadress[il+1]; aadress[il+1]=abi;}} } System.out.println("vahe"); for(i=0; i