import java.net.*; import java.io.*; import java.util.regex.*; public class Veebilugeja3{ static String aadress="http://www.hk.tlu.ee/index.php"; public static void uuriRida(String rida){ Pattern muster=Pattern.compile("href=[\\\"']([^\\\"']+)"); Matcher m=muster.matcher(rida); while(m.find()){ try{ String viide=m.group(1); if(!viide.startsWith("http://")){ viide=new URL(new URL(aadress), viide).toString(); } System.out.println(viide); }catch(MalformedURLException ex){ System.out.println("Vigane aadress: "+ex.getMessage()); } } } public static void main(String argumendid[]) throws IOException{ BufferedReader sisse=new BufferedReader( new InputStreamReader(new URL(aadress).openStream()) ); String rida=sisse.readLine(); while(rida!=null){ uuriRida(rida); //System.out.println(rida); rida=sisse.readLine(); } } }