Displaying Contents of a file in a Table

Aim:
To write a java program to display the table using JTable component. Suppose that a table named Table.txt is stored in a text file. The first line in the file is the header, and the remaining lines correspond to rows in the table. The elements are separated by commas.

Description: 
JTable represents data in the form of a table. The table can have rows of data, and column headings. Read the first line in the file and by using String Tokenizer get the column headings and store it in a single dimensional array. Read the next lines in the file and by using String Tokenizer get the row data and store that data in two dimensional array. Attach scroll pane to JTable component and attach it to JFrame.

Program:
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.util.*;
class MyTable extends JFrame
{ JTable tab;
JScrollPane scrollPane;
Vector<String> initData = new Vector<String>();;
String data[][] ;
String cols[];
File file = null;
FileInputStream fis = null;
BufferedInputStream bis = null;
Scanner sc = null;
public MyTable()
{ Container c = getContentPane ();
c.setLayout (new FlowLayout ());
try
{
file = new File("D:\\jqr\\Table.txt");
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
sc = new Scanner( new InputStreamReader (bis) );
while (sc.hasNextLine())
{
initData.add( sc.nextLine());
}
StringTokenizer st = new StringTokenizer( initData.get(0), ",");
cols = new String[ st.countTokens() ];
data = new String[ initData.size()-1][st.countTokens()];
for( int i = 0; i< initData.size(); i++)
{ if( i== 0)
{ int j= 0;
while( st.hasMoreTokens() )
{ cols[j] = st.nextToken();
j++;
}
}
else
{
int k=0;
StringTokenizer str = new StringTokenizer( initData.get(i),",");
while( str.hasMoreTokens() )
{
data[i-1][k] = str.nextToken();
k++;
}
}
}
fis.close();
bis.close();
}
catch (FileNotFoundException e)
{ e.printStackTrace();
}
catch (IOException e)
{ e.printStackTrace();
}
JTable tab = new JTable (data, cols);
scrollPane = new JScrollPane(tab);
c.add(scrollPane);
}
}
class TableDemo
{
public static void main(String args[])
{
MyTable ob = new MyTable();
ob.setTitle("Table Demo");
ob.setSize(600,400);
ob.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE);
ob.setVisible( true );
}
}