import java.io.*; import java.net.*; import java.util.StringTokenizer; public class exam1{ public static void main(String argumendid[]) throws IOException{ BufferedReader klaviatuur=new BufferedReader( new InputStreamReader(System.in) ); PrintWriter valja=new PrintWriter( new FileWriter("html.txt") ); int loendur=0; System.out.println("Palun URL:"); System.out.println(""); String url=klaviatuur.readLine(); BufferedReader sisse=new BufferedReader( new InputStreamReader( new URL(url).openConnection(). getInputStream() ) ); String rida=sisse.readLine(); while(rida!=null){ StringTokenizer st=new StringTokenizer(rida, " \"><"); while(st.hasMoreTokens()){ String sona=st.nextToken(); if(sona.startsWith("http:")){ System.out.println(sona); valja.println(sona); loendur = loendur + 1; } } rida=sisse.readLine(); } valja.println("URL-e on kokku "+loendur); valja.close(); System.out.println(""); System.out.println("URL-e on kokku "+loendur); } }