There are two methods for exactly this, in Files
final Path path myFile = Paths.get("path","to","file");
final byte[] toWrite = ...
Files.write(myFile, toWrite, StandardOpenOption.CREATE_NEW);
final byte[] read = Files.readAllBytes(myFile);
assert Arrays.equals(toWrite, read);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…