You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by Zulfi Khan <zu...@yahoo.com.INVALID> on 2021/03/12 04:50:13 UTC

Java filing problem on Netbeans 12.2: File created but no data in it

Hi,I am trying to run the following program:
ackage com.mycompany.fileWrite;
import java.io.File;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.IOException;

/**
 *
 * @author zulfi
 */
public class Main {
    public static void main( String[] args ) {

      try {
         String data = " Tutorials Point is a best website in the world";
         File f1 = new File("/home/zulfi/abc.txt");
         if(!f1.exists()) {
            f1.createNewFile();
         }

         FileWriter fileWritter = new FileWriter(f1.getName(),true);
         BufferedWriter bw = new BufferedWriter(fileWritter);
         bw.write(data);
         bw.close();
         System.out.println("Done");
      } catch(IOException e){
         e.printStackTrace();
      }
   }
    
}



But when I am checking the file there is no data in the file.
Somebody please guide me.
Zulfi.

Re: Java filing problem on Netbeans 12.2: File created but no data in it

Posted by "Mark A. Flacy" <mf...@verizon.net.INVALID>.
Greetings,

This is a generic Java problem, not a NetBeans issue.

Try */FileWriter fileWritter = new FileWriter(f1, true); /*instead.

-- 
Mark A. Flacy
mflacy@verizon.net

On Friday, March 12, 2021 7:01:44 PM CDT Zulfi Khan wrote:
> Hi,
> Subject: File created but message not stored
> Thanks Mark,
> Following is my program related to filing
> 
> package com.mycompany.fileWrite;
> import java.io.File;
> import java.io.FileWriter;
> import java.io.BufferedWriter;
> import java.io.IOException;
> 
> /**
>  *
>  * @author zulfi
>  */
> public class Main {
>     public static void main( String[] args ) {
> 
>       try {
>          String data = " Tutorials Point is a best website in the world";
>          File f1 = new File("/home/zulfi/abc.txt");
>          if(!f1.exists()) {
>             f1.createNewFile();
>          }
> 
>          FileWriter fileWritter = new FileWriter(f1.getName(),true);
>          BufferedWriter bw = new BufferedWriter(fileWritter);
>          bw.write(data);
>          bw.close();
>          System.out.println("Done");
>       } catch(IOException e){
>          e.printStackTrace();
>       }
>    }
>     
> }
> 
> I am running the above program on Ubuntu 18.04 using Netbeans 12.2. My
> project name is: "fileWrite". It is a Mavern, Java Application project. It
> is not writing anything in the file abc.txt:
> 
>  zulfi@lc2530hz:~$ cat abc.txt
> zulfi@lc2530hz:~$ pwd
> /home/zulfi
> zulfi@lc2530hz:~$
> 
> I have also attached the project image.
> Zulfi.
> 
> 
> 
>     On Friday, March 12, 2021, 6:50:48 PM CST, Zulfi Khan
> <zu...@yahoo.com> wrote:
> 
> 
> Hi,
> Thanks Mark,
> Following is my program related to filing
> 
> package com.mycompany.fileWrite;
> import java.io.File;
> import java.io.FileWriter;
> import java.io.BufferedWriter;
> import java.io.IOException;
> 
> /**
>  *
>  * @author zulfi
>  */
> public class Main {
>     public static void main( String[] args ) {
> 
>       try {
>          String data = " Tutorials Point is a best website in the world";
>          File f1 = new File("/home/zulfi/abc.txt");
>          if(!f1.exists()) {
>             f1.createNewFile();
>          }
> 
>          FileWriter fileWritter = new FileWriter(f1.getName(),true);
>          BufferedWriter bw = new BufferedWriter(fileWritter);
>          bw.write(data);
>          bw.close();
>          System.out.println("Done");
>       } catch(IOException e){
>          e.printStackTrace();
>       }
>    }
>     
> }
> 
> I am running the above program on Ubuntu 18.04 using Netbeans 12.2. My
> project name is: "fileWrite". It is a Mavern, Java Application project. It
> is not writing anything in the file abc.txt:
> 
>  zulfi@lc2530hz:~$ cat abc.txt
> zulfi@lc2530hz:~$ pwd
> /home/zulfi
> zulfi@lc2530hz:~$
> 
> I have also attached the project image.
> Zulfi.
> 
> 
>     On Friday, March 12, 2021, 12:20:58 AM CST, Mark A. Flacy
> <mf...@verizon.net.invalid> wrote:
> 
>  Greetings,
> 
> You are going to need to provide a lot more information before anyone even
> attempts to help you.
> 
> Why is this a Netbeans problem?  Did you make a project of some kind?  If
> so, what type of project?  What did you do via Netbeans?
> 
> You are essentially saying "I did some things and I expected some other
> things to happen, but those other things didn't happen.  Please help."
> 
> No one on this mailing list is paid by anyone to provide help; you are at
> the mercy of volunteers, who might provide help if there is an indication
> of some level of effort from the person requesting such help.
> 
> Please provide more detail upon what you did using Netbeans and what you

Re: Java filing problem on Netbeans 12.2: File created but no data in it

Posted by Mark Eggers <it...@yahoo.com.INVALID>.
This works as expected on:

Ubuntu 20.04 LTS
Java 11.0.10 2021-01-19 (AdoptOpenJDK)
NetBeans 12.3 installed via SNAP

. . . just my two cents
/mde/

On 3/12/2021 5:01 PM, Zulfi Khan wrote:
>   
> Hi,
> Subject: File created but message not stored
> Thanks Mark,
> Following is my program related to filing
> 
> package com.mycompany.fileWrite;
> import java.io.File;
> import java.io.FileWriter;
> import java.io.BufferedWriter;
> import java.io.IOException;
> 
> /**
>   *
>   * @author zulfi
>   */
> public class Main {
>      public static void main( String[] args ) {
> 
>        try {
>           String data = " Tutorials Point is a best website in the world";
>           File f1 = new File("/home/zulfi/abc.txt");
>           if(!f1.exists()) {
>              f1.createNewFile();
>           }
> 
>           FileWriter fileWritter = new FileWriter(f1.getName(),true);
>           BufferedWriter bw = new BufferedWriter(fileWritter);
>           bw.write(data);
>           bw.close();
>           System.out.println("Done");
>        } catch(IOException e){
>           e.printStackTrace();
>        }
>     }
>      
> }
> 
> I am running the above program on Ubuntu 18.04 using Netbeans 12.2. My project name is: "fileWrite". It is a Mavern, Java Application project. It is not writing anything in the file abc.txt:
> 
>   zulfi@lc2530hz:~$ cat abc.txt
> zulfi@lc2530hz:~$ pwd
> /home/zulfi
> zulfi@lc2530hz:~$
> 
> I have also attached the project image.
> Zulfi.
> 
> 
> 
>      On Friday, March 12, 2021, 6:50:48 PM CST, Zulfi Khan <zu...@yahoo.com> wrote:
>   
>    
> Hi,
> Thanks Mark,
> Following is my program related to filing
> 
> package com.mycompany.fileWrite;
> import java.io.File;
> import java.io.FileWriter;
> import java.io.BufferedWriter;
> import java.io.IOException;
> 
> /**
>   *
>   * @author zulfi
>   */
> public class Main {
>      public static void main( String[] args ) {
> 
>        try {
>           String data = " Tutorials Point is a best website in the world";
>           File f1 = new File("/home/zulfi/abc.txt");
>           if(!f1.exists()) {
>              f1.createNewFile();
>           }
> 
>           FileWriter fileWritter = new FileWriter(f1.getName(),true);
>           BufferedWriter bw = new BufferedWriter(fileWritter);
>           bw.write(data);
>           bw.close();
>           System.out.println("Done");
>        } catch(IOException e){
>           e.printStackTrace();
>        }
>     }
>      
> }
> 
> I am running the above program on Ubuntu 18.04 using Netbeans 12.2. My project name is: "fileWrite". It is a Mavern, Java Application project. It is not writing anything in the file abc.txt:
> 
>   zulfi@lc2530hz:~$ cat abc.txt
> zulfi@lc2530hz:~$ pwd
> /home/zulfi
> zulfi@lc2530hz:~$
> 
> I have also attached the project image.
> Zulfi.
> 
> 
>      On Friday, March 12, 2021, 12:20:58 AM CST, Mark A. Flacy <mf...@verizon.net.invalid> wrote:
>   
>   Greetings,
> 
> You are going to need to provide a lot more information before anyone even
> attempts to help you.
> 
> Why is this a Netbeans problem?  Did you make a project of some kind?  If so,
> what type of project?  What did you do via Netbeans?
> 
> You are essentially saying "I did some things and I expected some other things
> to happen, but those other things didn't happen.  Please help."
> 
> No one on this mailing list is paid by anyone to provide help; you are at the
> mercy of volunteers, who might provide help if there is an indication of some
> level of effort from the person requesting such help.
> 
> Please provide more detail upon what you did using Netbeans and what you
> expected Nebeans to do when you did whatever that was.


Re: Java filing problem on Netbeans 12.2: File created but no data in it

Posted by Zulfi Khan <zu...@yahoo.com.INVALID>.
 
Hi,
Subject: File created but message not stored
Thanks Mark,
Following is my program related to filing

package com.mycompany.fileWrite;
import java.io.File;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.IOException;

/**
 *
 * @author zulfi
 */
public class Main {
    public static void main( String[] args ) {

      try {
         String data = " Tutorials Point is a best website in the world";
         File f1 = new File("/home/zulfi/abc.txt");
         if(!f1.exists()) {
            f1.createNewFile();
         }

         FileWriter fileWritter = new FileWriter(f1.getName(),true);
         BufferedWriter bw = new BufferedWriter(fileWritter);
         bw.write(data);
         bw.close();
         System.out.println("Done");
      } catch(IOException e){
         e.printStackTrace();
      }
   }
    
}

I am running the above program on Ubuntu 18.04 using Netbeans 12.2. My project name is: "fileWrite". It is a Mavern, Java Application project. It is not writing anything in the file abc.txt:

 zulfi@lc2530hz:~$ cat abc.txt
zulfi@lc2530hz:~$ pwd
/home/zulfi
zulfi@lc2530hz:~$ 

I have also attached the project image.
Zulfi.



    On Friday, March 12, 2021, 6:50:48 PM CST, Zulfi Khan <zu...@yahoo.com> wrote:  
 
  
Hi,
Thanks Mark,
Following is my program related to filing

package com.mycompany.fileWrite;
import java.io.File;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.IOException;

/**
 *
 * @author zulfi
 */
public class Main {
    public static void main( String[] args ) {

      try {
         String data = " Tutorials Point is a best website in the world";
         File f1 = new File("/home/zulfi/abc.txt");
         if(!f1.exists()) {
            f1.createNewFile();
         }

         FileWriter fileWritter = new FileWriter(f1.getName(),true);
         BufferedWriter bw = new BufferedWriter(fileWritter);
         bw.write(data);
         bw.close();
         System.out.println("Done");
      } catch(IOException e){
         e.printStackTrace();
      }
   }
    
}

I am running the above program on Ubuntu 18.04 using Netbeans 12.2. My project name is: "fileWrite". It is a Mavern, Java Application project. It is not writing anything in the file abc.txt:

 zulfi@lc2530hz:~$ cat abc.txt
zulfi@lc2530hz:~$ pwd
/home/zulfi
zulfi@lc2530hz:~$ 

I have also attached the project image.
Zulfi.


    On Friday, March 12, 2021, 12:20:58 AM CST, Mark A. Flacy <mf...@verizon.net.invalid> wrote:  
 
 Greetings,

You are going to need to provide a lot more information before anyone even 
attempts to help you.

Why is this a Netbeans problem?  Did you make a project of some kind?  If so, 
what type of project?  What did you do via Netbeans?

You are essentially saying "I did some things and I expected some other things 
to happen, but those other things didn't happen.  Please help."

No one on this mailing list is paid by anyone to provide help; you are at the 
mercy of volunteers, who might provide help if there is an indication of some 
level of effort from the person requesting such help.

Please provide more detail upon what you did using Netbeans and what you 
expected Nebeans to do when you did whatever that was.

-- 
Mark A. Flacy
mflacy@verizon.net

On Thursday, March 11, 2021 10:50:13 PM CST Zulfi Khan wrote:
> Hi,I am trying to run the following program:
> ackage com.mycompany.fileWrite;
> import java.io.File;
> import java.io.FileWriter;
> import java.io.BufferedWriter;
> import java.io.IOException;
> 
> /**
>  *
>  * @author zulfi
>  */
> public class Main {
>    public static void main( String[] args ) {
> 
>      try {
>          String data = " Tutorials Point is a best website in the world";
>          File f1 = new File("/home/zulfi/abc.txt");
>          if(!f1.exists()) {
>            f1.createNewFile();
>          }
> 
>          FileWriter fileWritter = new FileWriter(f1.getName(),true);
>          BufferedWriter bw = new BufferedWriter(fileWritter);
>          bw.write(data);
>          bw.close();
>          System.out.println("Done");
>      } catch(IOException e){
>          e.printStackTrace();
>      }
>    }
>    
> }
> 
> 
> 
> But when I am checking the file there is no data in the file.
> Somebody please guide me.
> Zulfi.





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

    

Re: Java filing problem on Netbeans 12.2: File created but no data in it

Posted by "Mark A. Flacy" <mf...@verizon.net.INVALID>.
Greetings,

You are going to need to provide a lot more information before anyone even 
attempts to help you.

Why is this a Netbeans problem?  Did you make a project of some kind?  If so, 
what type of project?  What did you do via Netbeans?

You are essentially saying "I did some things and I expected some other things 
to happen, but those other things didn't happen.  Please help."

No one on this mailing list is paid by anyone to provide help; you are at the 
mercy of volunteers, who might provide help if there is an indication of some 
level of effort from the person requesting such help.

Please provide more detail upon what you did using Netbeans and what you 
expected Nebeans to do when you did whatever that was.

-- 
Mark A. Flacy
mflacy@verizon.net

On Thursday, March 11, 2021 10:50:13 PM CST Zulfi Khan wrote:
> Hi,I am trying to run the following program:
> ackage com.mycompany.fileWrite;
> import java.io.File;
> import java.io.FileWriter;
> import java.io.BufferedWriter;
> import java.io.IOException;
> 
> /**
>  *
>  * @author zulfi
>  */
> public class Main {
>     public static void main( String[] args ) {
> 
>       try {
>          String data = " Tutorials Point is a best website in the world";
>          File f1 = new File("/home/zulfi/abc.txt");
>          if(!f1.exists()) {
>             f1.createNewFile();
>          }
> 
>          FileWriter fileWritter = new FileWriter(f1.getName(),true);
>          BufferedWriter bw = new BufferedWriter(fileWritter);
>          bw.write(data);
>          bw.close();
>          System.out.println("Done");
>       } catch(IOException e){
>          e.printStackTrace();
>       }
>    }
>     
> }
> 
> 
> 
> But when I am checking the file there is no data in the file.
> Somebody please guide me.
> Zulfi.





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists