Latest LQ Deal: Linux Power User Bundle
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, 01: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, 03:44 AM   #2
LQ Guru
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 11,858

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

Rep: Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714
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 09:52 AM
[SOLVED] Want to create launcher for text-based Java program OmegaD Linux - Newbie 5 02-04-2012 09:16 PM
bash script to create text in a file or replace value of text if already exists knightto Linux - Newbie 5 09-11-2008 12:13 AM
text match pipe to file then delete from original text file create new dir automatic tr1px Linux - Newbie 6 09-10-2008 10:40 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:48 AM.

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