
Crear Ficheros
Publicado por rizis (2 intervenciones) el 07/02/2023 09:37:19
Buenos días, estoy intentando crear un fichero con una ruta, o directamente crear el fichero pero de ninguna manera me deja. El error permanece en la 4º fila cuando le indico la ruta
try {
//*1-Creo fichero
File fichero = New File("C:\\Users\\Rizis\\Documents\\Proyecto\\JavaApplication31\\src\\ProbandoFichero.txt"); //aqui esta el error
{
if (fichero.createNewFile()) {
System.out.println("Fichero con nombre: " + fichero.getName() + " ha sido creado");
} else {
System.out.println("El fichero ya existe");
}
fichero.close();
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
System.out.println("Error");
}
}
try {
//*1-Creo fichero
File fichero = New File("C:\\Users\\Rizis\\Documents\\Proyecto\\JavaApplication31\\src\\ProbandoFichero.txt"); //aqui esta el error
{
if (fichero.createNewFile()) {
System.out.println("Fichero con nombre: " + fichero.getName() + " ha sido creado");
} else {
System.out.println("El fichero ya existe");
}
fichero.close();
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
System.out.println("Error");
}
}
Valora esta pregunta


0