Кстати, наткнулся на вот такой код:
01 import java.io.*;
02 import java.net.*;
03 import java.util.regex.*;
04
05 /**
06 * This program displays all URLs in a web page by matching a regular expression that describes the
07 * <a href=...> HTML tag. Start the program as <br>
08 * java HrefMatch URL
09 * @version 1.01 2004-06-04
10 * @author Cay Horstmann
11 */
12 public class HrefMatch
13 {
14 public static void main(String[] args)
15 {
16 try
17 {
18 // get URL string from command line or use default
19 String urlString;
20 if (args.length > 0) urlString = args[0];
21 else urlString = "http://java.sun.com";
22
23 // open reader for URL
24 InputStreamReader in = new InputStreamReader(new URL(urlString).openStream());
25
26 // read contents into string builder
27 StringBuilder input = new StringBuilder();
28 int ch;
29 while ((ch = in.read()) != -1)
30 input.append((char) ch);
31
32 // search for all occurrences of pattern
33 String patternString = "<a\\s+href\\s*=\\s*(\"[^\"]*\"|[^\\s>]*)\\s*>";
34 Pattern pattern = Pattern.compile(patternString, Pattern.CASE_INSENSITIVE);
35 Matcher matcher = pattern.matcher(input);
36
37 while (matcher.find())
38 {
39 int start = matcher.start();
40 int end = matcher.end();
41 String match = input.substring(start, end);
42 System.out.println(match);
43 }
44 }
45 catch (IOException e)
46 {
47 e.printStackTrace();
48 }
49 catch (PatternSyntaxException e)
50 {
51 e.printStackTrace();
52 }
53 }
54 }
Написано что он показывает все URL в веб-странице. Сам не могу точно разобраться что к чему.