A simple Java class that gets the file CRC32 check code

zhaozj2021-02-16  77

A simple Java class that gets the file CRC32 check code

A simple Java class keyword for obtaining file CRC32 check code: Java, CRC. Starting from JDK1.4, the Java core package has been provided to CRC calculations. Here is a simple example, I hope to help you. Import java.util.zip.crc32; import java.util.zip.checkedInputStream; import java.io.fileinputStream; import java.io.file; / * * *

Title: *

Description: *

Copyright: CopyRight (C) 2003

*

Company: www.jagie.com * @Author jaige * @version 1.0 * / public class filetoCrcutil { public static String getFileCRCCode (File file) throws Exception {FileInputStream fileinputstream = new FileInputStream (file); CRC32 crc32 = new CRC32 (); for (CheckedInputStream checkedinputstream = new CheckedInputStream (fileinputstream, crc32);! checkedinputstream.read () = -1 ;) {} Return long.tohexstring (crc32.getValue ());} public static void main (string [] args) throws exception {file f = new file ("c: //ysfpcgl200311_237010400_jk.xml"); System.err .println (getfilecrccode (f));}}

转载请注明原文地址:https://www.9cbs.com/read-18306.html

New Post(0)