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

  • Home
  • SEARCH
  • 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 5844371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:16:59+00:00 2026-05-22T12:16:59+00:00

I have created a text file in which to store some variables which are

  • 0

I have created a text file in which to store some variables which are taken from text fields. But in order to submit new variables to this text file, I need to close my program and reopen it. The dispose(); command closes the JFrame taking me to my main menu but upon opening the menu again and submitting different values, the values from the previous time have been resubmitted. Is there a simple way to amend this?

Here is my write to .txt code:

public class writeto {

static String data = AddProperty.inputdata;
BufferedWriter out;

public writeto(){
        try{
            out = new BufferedWriter(new FileWriter("writeto.txt", true));

            out.write(data);

            out.newLine();

            out.close();

        }catch(IOException e){

            System.out.println("you have an error" + e);
        }
    }
}

and where the method is called in my addproperty class

        submitproperty.addActionListener(new ActionListener()
        {

        public void actionPerformed(ActionEvent e)
            {
              housenumber1 = houseNumber.getText();
              streetname1 = streetName.getText();
              town1 = town.getText();
              postcode1 = postcode.getText();
              beds1 = beds.getText();
              price1 = price.getText();
              type1 = type.getText();

            inputdata = housenumber1 + " " + streetname1 + " " + town1 + " " + 

            postcode1 +" " + beds1 + " " + price1 + " " + type1;

             writeto write = new writeto();
             dispose();
            }
       });
    }
  • 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-05-22T12:16:59+00:00Added an answer on May 22, 2026 at 12:16 pm

    You would benefit greatly from using a database as opposed to a text file. Further your question displays a fundamental lack of knowledge of not only Swing, but basic CRUD (Create, Read, Update, Delete) functionality.

    To answer your question you can clear your text field with textField1.setText(“”);

    I would read up on using a database for storing data. It will make life much easier for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a XML image gallery, which displays text in between each slide.
I have stored values retrieved from a text file into an array. Now am
I have a Python script that reads through a text csv file and creates
I have created an form validation using ajax/php. Each text box is validated using
I have created a non-form c# program that uses the NotifyIcon class. The text
alt text http://home.elka.pw.edu.pl/~pkolodzi/Capture.PNG I have created the IAdder interface with two methods: PassA and
I have a collection of nodes xml.dom.Node objects created using xml.dom.minidom. I store them
i have made user-register.tpl.php file. And i have set many text field in that.
I have craeted code which reads the acc no, rtn, name and amt from
I have seen some articles about HTML5 Manifest, which say that we must add

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.