I am creating a Junit test file for my CSVreader. I am reading the contents of CSV files and writing the contents to another file. I want to compare them using the diff utility, and I want to use the diff output status to find out if they match or not. Usually $? gives exit status, but I donβt know how to capture it and use it in my code. Can anyone help me in this regard?
This is what my code looks like
boolean hasSameContents = false; command="diff "+mp.get("directory")+"/"+fileName+" "+mp.get("outdir")+"/"+fileName; p= Runtime.getRuntime().exec(command); p.waitFor();
After that, I want to get the exit status and use it in the following conditions:
if(exit_status==0) hasSameContents = true; else hasSameContents = false;
Even alternative suggestions appreciated. :)
source share