文件比较API /代码

时间:2017-12-04 11:37:07

标签: java api file compare

我必须编写一个文件比较 - 仅(普通)文本文件和pdf文件 - 算法。我允许使用API​​或其他代码。

我发现了什么:

  • Google match-diff libs
  • Windows文件比较命令
  • Linux diff命令
  • 许多基于google api或来自linux的差异的lib

所以他们逐行比较两个文件,但如果我有这样的话:

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?如果您有更多问题,请告诉我。

提前感谢您的帮助

1 个答案:

答案 0 :(得分:0)

这看起来像是一个AI任务(理解语句类型等)。我正在制作这样的东西,但它还没有准备好。