-1

请举例说明以下语法:

static byte[] readAllBytes(Path path)
static Path write(Path path, byte[] bytes, OpenOption... options)

我对路径、字节但 OpenOption 有一个粗略的了解!所以最好举个例子。该代码与java 7有关。

4

2 回答 2

2

Files 类文档中有这样一个示例。

 Path path = ...
 byte[] bytes = ...
 Files.write(path, bytes, StandardOpenOption.APPEND);
于 2013-04-23T17:30:32.793 回答
0

代码示例:

Path path = Paths.get(pathToFile);
byte[] bArray = new byte[0];
try {
    bArray = Files.readAllBytes(path);
} catch (IOException e) {
    e.printStackTrace();
}
于 2014-04-14T07:19:46.153 回答