title: Read text file and display it in Jtable?
body: <p>i need to read the contents of text file, line by line and display it on the <code>Jtable</code>, the table should be editable by users as needed, Any help Appreciated. I am new to Java. Thank You.</p>
  
  <p>My Text File: File Name(people.txt)</p>
  
  <pre><code>COLUMN_NAME COLUMN_TYPE IS_NULLABLE COLUMN_KEY  COLUMN_DEFAULT  EXTRA   
  Names   VARCHAR(500)    NO  
  Address VARCHAR(500)    NO
  </code></pre>
  
  <p>My Code So Far:</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.DataInputStream;
  import java.io.FileInputStream;
  import java.io.InputStreamReader;
  import java.util.Vector;
  import javax.swing.JScrollPane;
  import javax.swing.JTable;
  import javax.swing.table.DefaultTableModel;
  public class readtext {
      static public void main(String[] arg){
          JScrollPane scroll;
          JTable table;
          DefaultTableModel model;
          String fname="people";
          try
          {
              FileInputStream fstream = new FileInputStream("D:/joy/text/"+fname+".txt");
  
  
              BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
              String strLine,str = null;
              //Read File Line By Line
              String text = "";
              Vector myVector = new Vector();
              while ((strLine = br.readLine()) != null) //loop through each line
              {
                  myVector.add(strLine );
                  // Print the content on the console
                  text +=(strLine+"\n");  // Store the text file in the string
              }
              in.close();//Close the input stream
              int i=0;
              String fline=myVector.elementAt(0).toString();
              String[] sp=fline.split("\\s+");
              for(String spt:sp){
                  System.out.println(spt);
                  //model = new DefaultTableModel(spt, );   // I dont know how to put the strings
                  into Jtable here
                  table = new JTable(){
                      public boolean isCellEditable(int row, int column){
                          return false;
                      }
                  };
                  int a=0;// for text box name
                  for(i=1;i&amp;lt;myVector.size();i++){
                      str=myVector.elementAt(i).toString();
                      String[] res =str.split("\\s+");
                      int k=0;
                      for(String st:res)
                      System.out.println(st);
                  k++;a++; }
          } }
          catch(Exception e)
          {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>Thank You.</p>