简体   繁体   中英

How to save changes made to jTable

My question is , how to save changes made to jTable?

I want to save changes made to jTable by adding save button in my program, but I don't know the source code of save button.

Please Help , can anybody send me the source code of save button.

I recommend saving your data in a output file. Going off of camickr's point, you can use the accessibility of JTable to help you save the data. To do this, I recommend using a PrintWriter . I can try to help you with the data types more if you specify what kind of data you are trying to save. I have attached a simple implementation of the PrintWriter class that saves a string.

import java.io.PrintWriter;
import java.io.File;
import java.io.FileNotFoundException;

public class Testing {

  public static void main(String[] args) throws FileNotFoundException
  {
    File file = new File ("file.txt");
    PrintWriter printWriter = new PrintWriter ("file.txt");
    printWriter.println ("hello");
    printWriter.close ();       
  }
}

This class will save the word "hello" to a file called "file.txt".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM