Check if specific pattern exists in another array and save the index
Naming



NOTE: headerArray is the large array.



If you need to specify this to us, then your variable name isn't good. We should be able to understand your code with only your code because you wouldn't be beside us when we read it.

Don't worry about using full names for your variables. After all, is there a real difference between idxP and indexPosition apart from the fact that it's very clear I'll understand the latter one?

Commenting
Every time you want to write a comment, ask yourself if it is necessary. When you think it is, think again! :p Comments suck (I'm not really talking about XML comments on methods and classes and etc). When you write a comment in a method, it's because there's something weird enough that you'd feel the need to explain why you did something much more than what you did. In your cases, I don't think the comments are necessary.
Readability
In my opinion, there are two great and easy ways to make code more readable.

Extracting methods : Taking small chunks of your code that fills a single purpose and make a method out of it.

Reduce nesting : Remove as much forking as possible (if, while, for, etc.)


When dealing with algorithms, it's often hard to extract methods as many things are dependent.
However, you have lots of forking, so we can work with that.
if (pattern.length == 1) {
    if (pattern[0].equals(headerArray[idxH])) {
        allPositions.add(idxH);
    }
}

Everytime (exceptions might apply lol) you have two if stuck one to another, they can be merged using the AND (&amp;&amp;) operator.
if (pattern.length == 1 &amp;&amp; pattern[0].equals(headerArray[idxH])) {
    allPositions.add(idxH);
}    

Bam, nesting reduced.
You should try to find other ways to reduce nesting, but again, coding complex algorithms often imply spaghetti-ish code. And in this case, you might want to write a meaningful comment as to why your code is this way.
What's next?
If you really want to reach great performance for a &quot;large&quot; array, you might want to consider looking at String searching algorithms. It's not an exact fit to your problem, but there's something to be done.
Small nitpick : Large has a vague definition. If you want to make your code as correct as possible regarding your input, it can be useful to know an approximation of how much data your working with. For you, maybe an array with 100 elements is large, but for some data scientist at IBM, maybe it's 15000000.