Java

Java 获取文件MD5

public static byte[] getFileMD5(String filename) {
	try {
		InputStream fis = new FileInputStream(filename);
		byte[] buffer = new byte[1024];
		MessageDigest complete = MessageDigest.getInstance("MD5");
		int numRead;
			do {
			numRead = fis.read(buffer);
			if (numRead > 0) {
				complete.update(buffer, 0, numRead);
			}
		} while (numRead != -1);
			fis.close();
		return complete.digest();
	} catch (Exception e) {
		e.printStackTrace();
	}
	return null;
}