【发布时间】:2017-12-04 11:37:07
【问题描述】:
我必须编写一个文件比较 - 仅(纯)文本文件和 pdf 文件 - 算法。我允许使用 API 或其他代码。
我发现了什么:
- Google 匹配差异库
- Windows 文件比较命令
- Linux 差异命令
- 许多基于 google api 或 linux 差异的库
所以他们逐行比较两个文件,但如果我有这个:
package pack1;
some imports
/**
*
* @author author1
*/
public class Class1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.print("ABaBAb " + count("ABaBAb") + "\n");
System.out.print("ABCabC " + count("ABCabC") + "\n");
System.out.print("ABaBAb " + count("ABaBAb") + "\n");
System.out.print("ABCDabdf " + count("ABCDabdf") + "\n");
System.out.print("ABCab " + count("ABCab") + "\n");
}
static HashMap<String, Integer> cache = new HashMap<>();
public static int count(String s) {
does something
}
}
还有这个:
package pack2;
some imports
/**
*
* @author changed
*/
public class Class2 {
static HashMap<String, Integer> cache = new HashMap<>();
public static int count(String s) {
does something
}
public static void main(String[] args) {
System.out.print("asdff " + countDifferentChars("asdff") + "\n");
System.out.print("Afda " + countDifferentChars("Afda") + "\n");
System.out.print("ABab " + countDifferentChars("ABab") + "\n");
System.out.print("sadr " + countDifferentChars("sadr") + "\n");
System.out.print("Afasd " + countDifferentChars("Afasd") + "\n");
}
}
他们并不真正了解差异,因为正如我所说,他们逐行比较。我正在寻找应该知道该包的东西, System.out.print 和其他东西几乎相同。它还应该能够分辨出计数方法是相同的(它们只是被移动了)。
是否有任何 API 能够做到这一点?如果您还有其他问题,请告诉我。
提前感谢您的帮助
【问题讨论】: