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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started