title: Get index that contains ".txt" in the list without using loop in JAVA
body: <p>I would like to get the first index of a string that contains a <code>&quot;.txt&quot;</code> in the list using JAVA. without doing any loop. Because I have lots of value in File like :</p>
  <pre><code>[&quot;sample.txt&quot;, &quot;sample.csv&quot;,&quot;sample.docx&quot;,&quot;sample&quot;,&quot;sample.xlsx&quot;,&quot;sample2.txt, ...];
  </code></pre>
  <p>I only need the index of <strong>&quot;sample.txt&quot;</strong></p>
  <pre><code>List&lt;String&gt; files = Arrays.asList(fileList).stream()
                               .map(x -&gt; x.getAbsolutePath())
                               .collect(Collectors.toList());
  index = files.indexOf(?);
  </code></pre>