import java.util.*; import java.net.*; import java.io.*; class s05 { static String masin="http://www.yahoo.com"; static String kohakene="http://www.yahoo.com"; static String aadress[]=new String[1000]; static String puhas[]=new String[1000]; static String juures[]=new String[1000]; static String kataloog,abi, viimane; static int aarv=0, parv=0, jarv=0, i; static int reas=0, failiviga; public static void loe(){ try { URL yahoo = new URL(kohakene); 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); failiviga=1; } catch (IOException ioe) { System.out.println("IOException: " + ioe); failiviga=1; } } public static void muuda(){ for(i=0; i-1) aadress[i]=aadress[i].substring(0,aadress[i].indexOf("?")); //System.out.println(aadress[i]+" uus"); } } public static void sordi(){ 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;}} } } public static void main(String[] args) { masin="http://www.yahoo.com"; kohakene="http://www.yahoo.com"; parv=0; loe(); muuda(); sordi(); //for(i=0; i