java-diff-utils icon indicating copy to clipboard operation
java-diff-utils copied to clipboard

File format

Open dfdfdfs opened this issue 3 years ago • 1 comments

Hello. Does the library only support txt files? Binary files not?

dfdfdfs avatar Jul 03 '22 09:07 dfdfdfs

This library supports it all :).

Look into test DuffUtilsTest.testDiffIntegerList.

@Test
    public void testDiffIntegerList() {
        List<Integer> original = Arrays.asList(1, 2, 3, 4, 5);
        List<Integer> revised = Arrays.asList(2, 3, 4, 6);

        final Patch<Integer> patch = DiffUtils.diff(original, revised);

        for (AbstractDelta<Integer> delta : patch.getDeltas()) {
            System.out.println(delta);
        }

        assertEquals(2, patch.getDeltas().size());
        assertEquals("[DeleteDelta, position: 0, lines: [1]]", patch.getDeltas().get(0).toString());
        assertEquals("[ChangeDelta, position: 4, lines: [5] to [6]]", patch.getDeltas().get(1).toString());
    }

here integers are processed. So you could read a file into a bytebuffer and process this data.

wumpz avatar Jul 09 '22 15:07 wumpz