Using FileUtils:
- import java.io.File;
- import org.apache.commons.io.FileUtils;
- public class CompareFileContent {
- public static void main(String[] args) throws Exception {
- File file1 = new File("D:\\data.txt");
- File file2 = new File("D:\\data1.txt");
- boolean isEqual = FileUtils.contentEquals(file1, file2);
- System.out.println(isEqual == true ? "equal" : "not equal");
- }
- }
Output:
equal
data.txt - file:
Hi guys !!
This is Ishaan from India.
and I'm reading the data from a text file line by line using BufferedReader.
Isn't it interesting !! to read the data from a file line by line
irrespective of amount of data that a file is having.
data1.txt - file:
Hi guys !!
This is Ishaan from India.
and I'm reading the data from a text file line by line using BufferedReader.
Isn't it interesting !! to read the data from a file line by line
irrespective of amount of data that a file is having.
No comments:
Post a Comment