title: Read the first word of each line from a text file and then populate to Combo box
body: <p>I have college project where i have to read the first word of every line from text file which looks as follow:</p>
  
  <pre><code>23123123213 Samuel classA
  23423423423 Gina classC
  23423423423 John classD
  </code></pre>
  
  <p>The text file will be updated with through 3 <code>JTextField</code> which i am able to figure out.</p>
  
  <p>but now i have to populate the <code>JCombobox</code> with first word(23123123213,23423423423 and 23423423423) of all the lines.</p>
  
  <p>I am new to java, i dont even have hint of how about doing it.
  I know how to read and write to text files.</p>
  
  <p>Please could someone help me do this?</p>
  
  <p>The code so far i came up with is as follows:</p>
  
  <pre><code>import java.io.*;
  public class FileRead 
  {
   public static void main(String args[])
    {
    try{
    // Open the file that is the first 
    // command line parameter
    FileInputStream fstream = new FileInputStream("RokFile.txt");
    // Get the object of DataInputStream
    DataInputStream in = new DataInputStream(fstream);
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String strLine;
    //Read File Line By Line
    while ((strLine = br.readLine()) != null)   {
  
        String[] delims = strLine.split(" ");
        String first = delims[0];
        System.out.println("First word: "+first);
  
    }
    //Close the input stream
    in.close();
      }catch (Exception e){//Catch exception if any
    System.err.println("Error: " + e.getMessage());
    }
    }
  }
  </code></pre>
  
  <p>With u guys help I was successfully able to extract the first string from each line
  but now how could i populate it in Jcombobox, I mean should i save it somewhere first?</p>
  
  <p>Thanks in Advance</p>