0
我想使用字幕API。它需要视频文件的第一个和最后一个64kb的md5散列。 我知道如何做md5部分只是想知道我将如何实现获得128kb的数据。如何读取Java中第一个和最后一个64kb的视频文件?
在Python中给出了一个API的例子,但遗憾的是我不理解它。
#this hash function receives the name of the file and returns the hash code
def get_hash(name):
readsize = 64 * 1024
with open(name, 'rb') as f:
size = os.path.getsize(name)
data = f.read(readsize)
f.seek(-readsize, os.SEEK_END)
data += f.read(readsize)
return hashlib.md5(data).hexdigest()
任何帮助,将不胜感激。
你想知道如何在Java中读取数据的64KB? – crush
[优雅的方式来读取文件到Java中的byte \ [\]数组]的可能重复(http://stackoverflow.com/questions/6058003/elegant-way-to-read-file-into-byte-array-in -java) – crush
是的。 该文件的第一个64kb和最后一个64kb。结合。 –