I have a piece of code that generates a json file. I am writing a unit test to compare the contents of this file against expected output. I use the code snippet
Assert.assertEquals(FileUtils.readLines(outputFile),
FileUtils.readLines(new File("expected.json")));
Now, the json generator writes json file using its own formatting, so I just want to compare the contents of two files and trim all spaces,newlines from both while comparing. What is the best way to do this without reading line by line?