Mi programa empieza con:
Código:
public static void main(String args[]){
Estructura e=new Estructura();
try{
e.cargarDatos();
}
catch (Exception er){
es.mensaje(er.toString());
}
La clase estructura es asi:
Código:
class Estructura {
private File f;
private Vector lista;
public Estructura(){
f=new File("datos.txt");
lista=new Vector();
}
public void cargarDatos() throws Exception{
if(!f.exists())
throw new Exception ("Error en acceso al fichero");
else {
if(!f.canRead())
throw new Exception ("Error en lectura del fichero");
else {
FileInputStream fis=new FileInputStream(f);
...............
fis.close();
if (cadena.length()>1)
volcar(cadena);
}
}
}
Cuando entro en el programa la primera vez se muestra el mensaje "Error de
acceso al fichero" recogido en la excepción. Es que al hacer new
File("datos.txt") no se crea el fichero?
Saludos