title: fast and efficient way to read tab separated file using java
body: <p>What is the most efficient way (In terms of time) to read a text file into a list of array. File are of size  100 mb to 2 gb. The file contains data in following formatted :</p>
  
  <pre><code>From      TO          time     
  
  a         b      13 decc 2009
  b         c      13 decc 2009
  c         d      13 decc 2009
  f         h      13 decc 2009
  f         g      13 decc 2009
  </code></pre>
  
  <p><strong>Edit:</strong> 
  Following is code for reading file</p>
  
  <pre><code>public List&lt;InputDataBean&gt; readInputData() throws Exception{
          List&lt;InputDataBean&gt; dataSet = new ArrayList&lt;InputDataBean&gt;();
          FileInputStream fstream = null;
          BufferedReader br = null;
          try{
              fstream = new FileInputStream(filePath);
              br = new BufferedReader(new InputStreamReader(fstream));
              String strLine;
              Set&lt;String&gt; users = new TreeSet&lt;String&gt;();
              while ((strLine = br.readLine()) != null)   {
                  InputDataBean data = validateRecord(strLine);
                  if(data==null)
                      continue;
                  dataSet.add(data);
                  users.add(data.getFromName());
                  users.add(data.getToName());
              }
              UserKeys.setUsers(users);
  
          }catch (Exception e){
              throw e;
          }finally{
              try {
                  if(null!=br)
                      br.close();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return dataSet;
      }
  </code></pre>
  
  <p>After reading file I want to store into array not to database.</p>
  
  <p>If any other better alternative for reading file? Is it good idea to call script from java program and read data using script and store into java array. </p>
  
  <p>P.S.: I really appreciate if anybody can edit or improve tags. </p>