grazie ragazzi
quindi in questo modo è giusto
codice:
class Weditor {
StringBuffer $_buffer_ = new StringBuffer();
int $_curPos_ = 0;
/** ----------------------------------------------- **/
public Weditor(String nomefile) throws FileNotFoundException
{
File f = new File(nomefile);
int ch;
if(f.exists())
{
try {
FileInputStream fis = new FileInputStream(nomefile);
InputStreamReader isr = new InputStreamReader(fis, "UTF8");
Reader in = new BufferedReader(isr);
while ((ch = in.read()) > -1) {
$_buffer_.append((char)ch);
}
in.close();
} catch (IOException e) {
System.out.println(e.getMessage());
}
} else {
throw new FileNotFoundException("File non trovato.");
}
}
}
e questa la classe di test
codice:
public class testWeditor {
/** Creates a new instance of testWeditor */
public static void main(String args[]) {
try{
Weditor we = new Weditor("c:/java_test/prov.txt");
}catch (FileNotFoundException e) {
System.out.println(e.getMessage());
}
}
}