Search code examples
javaparsingassert

How to skip a row in Java when asserting text


I have the following .txt file:

Fuzzy search: 
A line of text I would like to skip.
YES
Other text...

How can I assert that the file contains "Fuzzy search" and "YES" two lines below?


Solution

  • A simple approach:

    • you read the file line by line (and remember the line number)
    • when you hit "Fuzzy search:", you remember the line where you found it
    • when you hit "YES" ... you check if you had a "Fuzzy search" hit, and if so, you check corresponding line number

    ( as you didn't show any code of yourself, I assume you are merely looking for guidance, which ... you got here. If you need more details, consider adding more details to your question )