Help. The program should display the title of the web page. I do not understand what the error is.
public static String httpTitle(URL url) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String str; String title = ""; String pattern = "(?i)<title([^>]+)>(.+?)</title>"; while ((str = in .readLine()) != null) { Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(str); m.matches(); title = m.group(3); } in .close(); return title; } public static void main(String[] args) throws MalformedURLException, IOException { URL url = new URL("http://www.google.com.ua"); System.out.print(httpTitle(url)); }
(?i)<title([^>]+)>(.+?)</title>
- well, what is it? Tin ... What does this have to do with programming - this is stupid shamanism! - Barmaley