Originariamente inviato da nikynik
ti ringrazio ma potresti farmi un esempio da studiarmi e capire come realizzare la ricerca
sto cercando di capire infatti lafunzionalità di matcher, ma sono tanti i possibili usi...
ti ringrazio
Ok, ti posto un esempio completo e funzionante. Studialo bene. 
codice:
import java.io.*;
import java.util.regex.*;
public class Prova
{
public static void main (String[] args)
{
if (args.length == 1)
{
try
{
String testoPagina = leggiFile (args[0]);
Pattern pattern = Pattern.compile ("<title>(.*?)</title>", Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher (testoPagina);
if (matcher.find ())
{
String titolo = matcher.group (1);
System.out.println ("Il titolo della pagina e`: " + titolo);
}
}
catch (Exception e)
{
System.out.println (e);
}
}
}
public static String leggiFile (String nomeFile)
throws IOException
{
InputStream is = null;
InputStreamReader isr = null;
StringBuffer sb = new StringBuffer ();
char[] buf = new char[1024];
int len;
try
{
is = new FileInputStream (nomeFile);
isr = new InputStreamReader (is);
while ((len = isr.read (buf)) > 0)
sb.append (buf, 0, len);
return sb.toString ();
}
finally
{
if (isr != null)
isr.close ();
}
}
}