title: String Trimming Exception
body: <p>Hey Guys i have a weird Problem,
  I want to parse a Channel Template from a Website.
  What works:
  Parsing File and cutting from the Beginning (e.g only German Channels), but cuting from the end of a Line always ends up in a Index out of Range -1 Exception
  Dont know why.</p>
  
  <p>Disclamer: This is only a Dummy File the channels are not working!!
  So don't except free TV or something.</p>
  
  <pre><code>public static void main(String[] args) throws Exception {
      {
          String url = "http://www.vjackson.info//live/index";
          final String USER_AGENT = "VAVOO/1.51";
          URL obj = new URL(url);
          HttpURLConnection con = (HttpURLConnection) obj.openConnection();
  
          //add reuqest header
          con.setRequestMethod("POST");
          con.setRequestProperty("User-Agent", USER_AGENT);
          con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
  
          final String trimFromLine = "no mather whats in here it dont work";
          final String searchKey = "#EXTINF:-1 tvg-name=\"13TH STREET FHD";
          String result = "";
  
          // Send post request
  
          BufferedReader in = new BufferedReader(
              new InputStreamReader(con.getInputStream()));
          String inputLine = "";
          StringBuffer response = new StringBuffer();
  
          while ((inputLine = in.readLine()) != null) {
              response.append(inputLine);
              if (response.toString().contains(searchKey)) {
                  result=response.toString().substring(response.toString().indexOf(searchKey));
  
                  String result2 = result.substring(0, result.indexOf(trimFromLine));
  
              }
  
  
          }
          in.close();
          System.out.println(result);
  
          //print result
  
  
      }
  
  }
  }
  </code></pre>