title: Java .split() out of bounds
body: <p>I have a problem with my code.</p>
  
  <p>I'm trying to extract the name of the channels from a .txt file.
  I can't understand why the method <code>line.split()</code> give me back an array with 0 length:</p>
  
  <p>Someone can help me? </p>
  
  <p>This is the file .txt:</p>
  
  <p>------------[channels.txt]---------------------</p>
  
  <pre><code>...
  #CH id="" tvg-name="Example1" tvg-logo="http... 
  #CH id="" tvg-name="Example2" tvg-logo="http...
  #CH id="" tvg-name="Example3" tvg-logo="http...
  #CH id="" tvg-name="Example4" tvg-logo="http...
  ...
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>try {
      FileInputStream VOD = new FileInputStream("channels.txt");
      BufferedReader buffer_r = new BufferedReader(new InputStreamReader(VOD));
      String line;
      ArrayList&lt;String&gt; name_channels = new ArrayList&lt;String&gt;();
  
      while ((line = buffer_r.readLine()) != null ) {
          if (line.startsWith("#")) {
              String[] first_scan = line.split(" tvg-name=\" ", 2);
              String first = first_scan[1];               // &lt;--- out of bounds
  
              String[] second_scan = first.split(" \"tvg-logo= ", 2);
              String second = second_scan[0];
  
              name_channels.add(second);
  
          } else {
              //...           
          }
      }
      for (int i = 0; i &lt; name_channels.size(); i++) {
          System.out.println("Channel: " + name_channels.get(i));
      }
  } catch(Exception e) {
      System.out.println(e);
  }
  </code></pre>