如何从路径生成 Guava ByteSource?

How do I generate a Guava ByteSource from a Path?

我正在尝试使用 Guava 在 Path 处对文件进行哈希处理。我不能使用 File class 因为 JimFS 不支持它。

如果我有 File,我会使用这种 Guava 方法:

public static ByteSource asByteSource(File file)

是否有 Path 的等效项?

如果没有,我该如何实施?

如果你只能用Path,那就看看MoreFiles::asByteSource