come faccio a salvare l'output in un file txt?
vi posto il codice
import java.io.*;
import java.util.regex.*;
class Prova
{
public static void main (String[] args)
{
try
{
String testoPagina = leggiFile ("c:/Ingegneria/mysql/temp/pagina.txt");
Pattern pattern = Pattern.compile ("<SCRIPT.*?>(.*?)</SCRIPT>", Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher (testoPagina);
while (matcher.find ())
{
String script = matcher.group (0);
System.out.println ("SCRIPT:\n " + script);
}
}
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 ();
}
}
}
questo programma mi stampa l'outmput a video come faccio a salvare l'output su di un file txt
potreste aiutarmi