In my Selenium+Java automation framework, I need to open a .txt file or any other extension file and then see if the text is in a particular format. Now, I need to see if all lines are in this format and also, say in line 2, from substring (7,10) is 2000. Now, is there any method in FileUtils API?
I can open the file and assert that it exists. I am not able to validate File content. I need to do this as a part of my Automation project. this is indeed the purpose of my project to validate all file format contents.
Like:
0000000TEst 123 234 TEST22 refreence 0002343
00000002000 2343 23343 TEST22000000000000000000
000000003534 3434 34343 3434 343 343 TEst 0000000 000 000 001
Update in response to answers:
Thanks! this is very helpful, i will use this method to verify all the file formats with regex.
Also, once i validate the format, then i will validate some substrings. Now, i have the expected result of Substring stored in String line2Value = "2000";
if(line1.substring(7,10).equals(line2Value)){
// syso("This is correct....."
}
Now, I have such kind of a file in which some section of records, some regex repeats n number of times.
{1:TES001}{2:TEST002}{3:
:03:192sscE8wre
:04:TESTLIne
:05C:23434/23423
:06:/
:07:343434,434343//3434343434
:89:?This is test line / EXTRA TEXT LINE
-}
My file will have hundreds of these sections, that all start from {1:... and end with -89 }..
how i can check not just 1 section, but all of these groups are in the same format :/