Post
EN

이미지 비교 (image comparision)

public class ImageCompare { private String originPath; private String cdnPath; private boolean same = true; int b1 = 0, b2 = 0, pos = 1; public ImageCompare(String originPath, String cdnPath) { this.originPath = originPath; this.cdnPath = cdnPath; } public boolean compare() throws IOException { try ( BufferedInputStream compare1 = new BufferedInputStream(new URL(originPath).openStream()); BufferedInputStream compare2 = new BufferedInputStream(new URL(cdnPath).openStream()); ) { while (b1 != -1 && b2 != -1) { if (b1 != b2) { log.info(" two file was different. : {}, {}", originPath, cdnPath); same = false; break; } pos++; b1 = compare1.read(); b2 = compare2.read(); } } return same; } }

참고 : https://dzone.com/articles/comparing-files-in-java

Comparing Files in Java - DZone Java

This lesson in Java NIO and memory mapping involves creating a simple Java application to compare files while safeguarding performance.

This article is licensed under CC BY 4.0 by the author.