Suppose we are trying to find some string in a class, and suppose that class has this string repeated several times. How do I make the `.contains()` method stop whenever it finds the first match? Here is an example of what I mean:

```
      for (File f : list) {
        if (f.isDirectory()) {
            walk(f.getAbsolutePath());
        }

        if (f.getName().endsWith(".java")) {

            System.out.println("File:" + f.getName());
            countFiles++;

            Scanner sc2 = new Scanner(f);

            while (sc2.hasNextLine()) {

                count++;

                String str = sc2.nextLine();

                if (str.contains("@Test")) {
                    System.out.println("this is a test class");

                }

```

As you can see I'm trying to find test classes so I'm looking for `@Test` notation, the program is working perfectly, but in this case its printing (this is a test class) several times as the class that I am testing has four `@Test` notations!

Thanks!