Hi,
I am new and written code to compare 2 pdf file and create summary for in which lines change has done in another PDF file after compare both PDF. But my code is for word compare and it is not working for all lines. I need help for PDF or Word:
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class CompareTextFiles
{
public static void main(String[] args) throws IOException
{
BufferedReader reader1 = new BufferedReader(new FileReader("D:/Data/v1.docx"));
BufferedReader reader2 = new BufferedReader(new FileReader("D:/Data /v2.docx"));
String line1 = reader1.readLine();
String line2 = reader2.readLine();
boolean areEqual = true;
int lineNum = 1;
while (line1 != null || line2 != null)
{
if(line1 == null || line2 == null)
{
areEqual = false;
//break;
}
else if(! line1.equalsIgnoreCase(line2))
{
areEqual = false;
// break;
}
line1 = reader1.readLine();
line2 = reader2.readLine();
lineNum++;
}
if(areEqual)
{
System.out.println("Two files have same content.");
}
else
{
System.out.println("Two files have different content. They differ at line "+lineNum);
System.out.println("File1 has "+line1+" and File2 has "+line2+" at line "+lineNum);
}
reader1.close();
reader2.close();
}
}