Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-15-2018, 12:44 AM   #1
LQ Newbie
Registered: Jun 2018
Posts: 7

Rep: Reputation: Disabled
Unhappy Error when i create a file text with java

Hi all,

I'm getting some errors when I want to create a txt file with Java NetBeans. This is the error. /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


package utileria;


public class Archivos {

public static void crearArchivo(String nombreArchivo)
File archivo = new File(nombreArchivo);
PrintWriter salida = new PrintWriter(new FileWriter(archivo));
System.out.println("El archivo se ha creado correctamente");
catch(IOException io)

I know to the exception is giving me that error but i don't know how to change the folder as not a directory.

Old 07-15-2018, 02:44 AM   #2
LQ Guru
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 11,377

Rep: Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419Reputation: 3419
you might want to check the value of NOMBRE_ARCHIVO
Old 07-15-2018, 07:58 AM   #3
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
Assign a filename to the file you want to create
crearArchivo(NOMBRE_ARCHIVO + "filename.txt");


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
file command sees regular ASCII text file as ASCII Java program text bbraml Linux - Software 6 08-30-2013 08:52 AM
[SOLVED] Want to create launcher for text-based Java program OmegaD Linux - Newbie 5 02-04-2012 08:16 PM
bash script to create text in a file or replace value of text if already exists knightto Linux - Newbie 5 09-10-2008 11:13 PM
text match pipe to file then delete from original text file create new dir automatic tr1px Linux - Newbie 6 09-10-2008 09:40 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:44 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration