elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


  Mostrar Temas
Páginas: [1]
1  Programación / Java / Hola, me podrían ayudar con un error java? en: 7 Febrero 2023, 09:43 am
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 2º fila cuando le indico la ruta

Lo he intentado hacer de dos formas, 1- indicando directamente el nombre del fichero, 2- indicándole la ruta, no encuentro el error.

Código
  1.        try {
  2.            File fichero = New File("ProbandoFichero.txt");   // aqui esta el error
  3.            {
  4.                if (fichero.createNewFile()) {
  5.                    System.out.println("Fichero con nombre: " + fichero.getName() + " ha sido creado");
  6.                } else {
  7.                    System.out.println("El fichero ya existe");
  8.                }
  9.                fichero.close();
  10.            }
  11.        } catch (Exception e) {
  12.            System.out.println(e.getMessage());
  13.  
  14.        }
  15.        System.out.println("Error");
  16.    }
  17. }
  18. //////////////////////////////////////////////////////////////////////////////////////////////////
  19. try {
  20.  
  21. File fichero = New File("C:\\Users\\Rizis\\Documents\\Proyecto\\JavaApplication31\\src\\ProbandoFichero.txt"); //aqui esta el error
  22. {
  23. if (fichero.createNewFile()) {
  24. System.out.println("Fichero con nombre: " + fichero.getName() + " ha sido creado");
  25. } else {
  26. System.out.println("El fichero ya existe");
  27. }
  28. fichero.close();
  29. }
  30. } catch (Exception e) {
  31. System.out.println(e.getMessage());
  32.  
  33. }
  34. System.out.println("Error");
  35. }
  36. }
  37.  
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines