如何将 file 对象读成 数组

在 Java 7 中,使用下面的方法:

public class ContentToByteArrayExample { public static void main(String[] args) { Path path = Paths.get("C:/temp/test.txt"); byte[] data = Files.readAllBytes(path); } }