title: Read a file separated by tab and put the words in an ArrayList
body: <p>I am doing a self learning exercise to help me understand more about Java, but I am stuck at this question. I have the following txt file:</p>
  
  <pre><code>Name  Hobby 
  Susy  eat fish 
  Anna  gardening
  Billy bowling with friends
  </code></pre>
  
  <p>Note: <strong>name and hobby are separated by tab</strong></p>
  
  <p>What is the best way to read all the line and put it in arraylist(name,hobby). The tricky part is that</p>
  
  <pre><code>eat fish or bowling with friends
  </code></pre>
  
  <p>has white spaces and it must be put under one array and obviously I cannot hardcode it. Here is my current code:</p>
  
  <pre><code> public void openFile(){
              try{
                  FileInputStream fstream = new    FileInputStream("textfile.txt");
            // use DataInputStream to read binary NOT text
            BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
            ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;();
            ArrayList&lt;String&gt; hobbies = new ArrayList&lt;String&gt;();
            String lineJustFetched;
            while ((lineJustFetched = br.readLine()) != null)   {
            String[] tokens = lineJustFetched.split(" \t");
  </code></pre>
  
  <p>I got an error:</p>
  
  <blockquote>
    <p>java.lang.StringIndexOutOfBoundsException: String index out of range:
    -1</p>
  </blockquote>
  
  <p>I suspect counting the index is not very useful on a tab.
  Any idea?</p>