有没有办法在 Java 中获取 InputStream 的 HashCode,我正在尝试使用<p:fileUpload/>PrimeFaces 上传图片,将其转换为 HashCode 并将其与另一张图片进行比较。
目前我正在尝试这个:
public void save(FileUploadEvent event) throws IOException {
HashCode hashCode = null;
HashCode hashCodeCompare = null;
hashCode = Files.asByteSource(new File(event.toString())).hash(Hashing.murmur3_128(50));
hashCodeCompare = Files.asByteSource(new File(FilePathOfFileToCompare)).hash(Hashing.murmur3_128(50));
boolean hashTrueFalse;
if(hashCode.equals(hashCodeCompare)) {
System.out.println("true");
} else{
System.out.println("false");
}
try (InputStream input = event.getFile().getInputstream()) {
String imageName = generateFileName() + "." + fileExtensions(event.getFile().getFileName());
String imageLink = PICTURE_DESTINATION + "\\" + imageName;
Picture picture = new Picture();
picture.setPictureUrl(imageLink);
pictureService.createOrUpdate(picture);
personForm.getCurrentPersonDTO().setPictureDTO(pictureMapper.toDTO(picture));
} catch (IOException e) {
e.printStackTrace();
}
}
有没有办法把它InputStream变成哈希码?
POPMUISE
qq_遁去的一_1
宝慕林4294392
相关分类