Question: JAVA, how to save the data of the Jtable on a txt.file? and any changes made on execution are also made on the txt file

JAVA, how to save the data of the Jtable on a txt.file? and any changes made on execution are also made on the txt file and updated later.

import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable;

public class JTableExamples { // frame JFrame f; // Table JTable j;

// Constructor JTableExamples() { // Frame initiallization f = new JFrame();

// Frame Title f.setTitle("JTable Example");

// Data to be displayed in the JTable String[][] data = { { "Kundan Kumar Jha", "4031", "CSE" }, { "Anand Jha", "6014", "IT" } };

// Column Names String[] columnNames = { "Name", "Roll Number", "Department" };

// Initializing the JTable j = new JTable(data, columnNames); j.setBounds(30, 40, 200, 300);

// adding it to JScrollPane JScrollPane sp = new JScrollPane(j); f.add(sp); // Frame Size f.setSize(500, 200); // Frame Visible = true f.setVisible(true); }

// Driver method public static void main(String[] args) { new JTableExamples(); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!