title: Substring method to return start to string.length() if the end index is out of bounds?
body: <p>Basically the title.</p>
  <pre><code>String text = &quot;abcdef&quot;;
  String pattern = &quot;defg&quot;;
  int start = 3;
  int end = 3 + pattern.length();
  System.out.println(text.substring(start,end));
  </code></pre>
  <p>Now that throws index out of bounds error but is there some API that can work around this.
  Right now I'm just doing</p>
  <pre><code>if (end &gt; text.length()){
  end = text.length();
  }
  </code></pre>