So if my assumptions about your requirements are correct, you are searching for all occurrences of your search string in a larger string.
Here's my thinking/approach:
Let's say we have the following string to search: "this is a very long string to try to test!" and we are searching for the string: "tr".
We essentially have to search every possible substring of length 2 within this larger string, since we know any matching substring will be the same length just by definition.
So we'd start at index 0 through 2. This gives us "th". We compare and find no matches, so we increment the counter and go to index 1 through 3. This gives us "hi". We continue on like this.
Eventually we'd get matches on "str
ing" and "tr
y" and it'd return 2.
You can set up this process through a single for loop.
There's no need to convert everything to lowercase. ".equalsIgnoreCase" is a method that exists for this purpose.
Finally I'd break this apart into multiple different methods, even from what you have there. I'd make a method that takes in a String to search through, a String to search for, and returns a number of occurrences.
Here's a code sample with some TODO comments. Try to fill these in, and it'll work.
Some more general coding advice:
This while loop looks weird t me, since it seems like it'll just break out of the loop immediately on the first iteration.
I'd write this with a for each:
I don't think printing an ArrayList will give you any meaningful output, it probably just prints a memory address (maybe I'm wrong here?)
That's a lot of code written to read a file into a String. Try writing an implementation using a Scanner and you might find this easier to make (if you really want to, you can write this method in a single line
you just have to take advantage of the delimiter feature)
I'd declare this type as a List<String> rather than ArrayList<String> to make it more general: