Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9018957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:39:42+00:00 2026-06-16T04:39:42+00:00

I made a program to produce a file with numbers in it But the

  • 0

I made a program to produce a file with numbers in it
But the program is not typing any thing in the file it created!

This is the code:

     private void OpenMenuActionPerformed(java.awt.event.ActionEvent evt) {                                         
    ModFile=new File(NameText.getText() + ".mod");
    FileWriter writer = null;
    try {
        writer = new FileWriter(ModFile);
    } catch (IOException ex) {
        Logger.getLogger(ModMakerGui.class.getName()).log(Level.SEVERE, null, ex);
    }
   if(!ModFile.exists()){
   try {
   ModFile.createNewFile();
   System.out.println("Mod file has been created to the current directory");
   writer.write(CodesBox.getText());
   } catch (IOException ex) {
   Logger.getLogger(ModMakerGui.class.getName()).log(Level.SEVERE, null, ex);
       }
     }     
   }                      

When i create a random file, i don’t see any thing when i open it!
Please help
Thanks Amir for helping but i noticed i should use FileOutputStream and DataOutputStream…
So, i need help again cause the same problem appeared 🙁

 File ModFile =new File(NameText.getText() + ".mod");
try {
    FileOutputStream fos = new FileOutputStream(ModFile);
    DataOutputStream dos = new DataOutputStream(fos);
    int i = Integer.parseInt(CodesBox.getText());
    dos.writeInt(i);
        // and other processing 
} catch (IOException ex) {
    Logger.getLogger(ModMakerGui.class.getName()).log(Level.SEVERE, null, ex);
}finally{
    try{
         dos.close();
    } catch(IOException e) {
        e.printStackTrace();
    }
}

NetBeans said they cannot find the symbol dos at (dos.close();)

Please help me here again

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:39:43+00:00Added an answer on June 16, 2026 at 4:39 am
    • You have to check that file name is present in NameText.getText().
    • You dont need to create file, if file dont exist FileWriter will create it self.
    • You should Close file after processing

      private void OpenMenuActionPerformed(java.awt.event.ActionEvent evt) {

          //check before file name is nt null
          File ModFile =new File("somefile" + ".mod");
          FileWriter writer = null;
      
          try {
              writer = new FileWriter(ModFile);
              writer.write("test..................");
                  // and other processing 
          } catch (IOException ex) {
              Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
          }finally{
              try {
                  writer.close();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      
      }                    
      

    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    to use FileOutputStream and write byte array follow the following code

    private static void OpenMenuActionPerformed(java.awt.event.ActionEvent evt) {  
    
    //check before file name is nt null
        File ModFile =new File("somefile" + ".mod");
        FileOutputStream writer = null;
    
        String toProcess = "00D0C0DE00D0C0DE F000000000000000";
    
        try {
            writer = new FileOutputStream(ModFile);
            writer.write(toProcess.getBytes(),0,toProcess.getBytes().length);
    
        } catch (IOException ex) {
            Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
        }finally{
            try {
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made this program for a school, and it involves a telnet server. When
I have made a program that scans rss feeds. This same program creates feeds
I have made a program in Java that calculates powers of two, but it
I made a program in Idle that says: for trial in range(3): if input('Password:')
I made small program to divide large pictures and take part of them. When
I made a program that opens an application, sleeps the thread for 500ms then
I made a program which i want to launch with some protocal for eg
I made a program: import collections x = input(Enter in text: ) x_counter =
I've made a program to manage a movie collection and it stores the data
I have a program made up of several .h and .c files and a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.