Question: how do I display txt file data to a jtable? here's what I got so far for the text file data to read, but how

how do I display txt file data to a jtable? here's what I got so far for the text file data to read, but how do I get it to display on a table?

the departments.txt file only displays departments like in one row, separated by line like

Marketing

Accounting

Sales

public static void main(String[] args) { // TODO code application logic here try{ FileReader fr = new FileReader("Departments.txt"); BufferedReader br = new BufferedReader(fr); String departmentsTextFile; while ((departmentsTextFile = br.readLine()) != null){ out.println(departmentsTextFile); } br.close(); } catch(IOException e){ out.println("File not found test"); } java.io.File departmentsFile = new java.io.File("Departments.txt"); try { Scanner input = new Scanner(departmentsFile); while(input.hasNext()){ String num = input.nextLine();//grabs line ****HERE IS WHERE I WOULD ADD IT TO THE JTABLE CALLED ASSIGNMENTSTABLE -ONE COLUMN TOTAL } } catch (FileNotFoundException e){ System.err.format("File does not exist");

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!