Hi all,
I'm getting some errors when I want to create a txt file with Java NetBeans. This is the error.
java.io.FileNotFoundException: /home/tony/Documents/Java (Is a directory)
Here is the code.
package manejoarchivos;
import static utileria.Archivos.*;
public class ManejoArchivos {
//Nota: ya debe estar creada la carpeta sobre la cual se va a trabar
//Y en caso necesario se deben asignar permisos de escritura a la carpeta
private static final String NOMBRE_ARCHIVO = "/home/tony/Documents/Java/";
public static void main(String[] args) {
//Crear archivo
crearArchivo(NOMBRE_ARCHIVO);
}
class.::::::::::::::::::::::::::::
package utileria;
import java.io.*;
public class Archivos {
public static void crearArchivo(String nombreArchivo)
{
File archivo = new File(nombreArchivo);
try
{
PrintWriter salida = new PrintWriter(new FileWriter(archivo));
salida.close();
System.out.println("El archivo se ha creado correctamente");
}
catch(IOException io)
{
io.printStackTrace();
}
}
I know to the exception is giving me that error but i don't know how to change the folder as not a directory.
Thank