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
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