select first index in collection where like
<p>I feel sometimes that I'm reinventing the wheel.</p>

<p>I'm wondering if there are any utility methods in java/jakarta commons/guava/?, that will go deeper in the collection and do something (test, modify, remove) with the elements.</p>

<p>I wrote this method and now I feel that there is some one-liner that can do it.</p>

<pre><code>/**
 * Find index of first line that contains search string.
 */
public static int findIdx(List&lt;String&gt; list, String search) {
  for (int i = 0, n = list.size(); i &lt; n; i++)
    if (list.get(i).contains(search))
      return i;
  return -1;
}
</code></pre>
