Here you can find the source of indexOf(List
public static int indexOf(List<String> lines, String... conditions)
//package com.java2s; import java.util.List; public class Main { public static int indexOf(List<String> lines, String... conditions) { int i = 0; for (String line : lines) { if (matchLine(line, conditions)) return i; i++;/*from w ww.j a v a 2s . c o m*/ } return -1; } private static boolean matchLine(String line, String[] conditions) { for (String condition : conditions) { boolean exclude = false; if (condition.startsWith("\\")) { exclude = true; condition = condition.substring(1); } if (exclude && line.contains(condition)) return false; if (!exclude && !line.contains(condition)) return false; } return true; } }