September 2019
Intermediate to advanced
816 pages
18h 47m
English
An efficient way of writing binary files is by using BufferedOutputStream. For example, writing a byte[] to a file can be accomplished as follows:
final byte[] buffer...;Path classFile = Paths.get( "build/classes/modern/challenge/Main.class");try (BufferedOutputStream bos = newBufferedOutputStream( Files.newOutputStream(classFile, StandardOpenOption.CREATE, StandardOpenOption.WRITE))) { bos.write(buffer);}
A very handy method for writing a byte[] to a file is Files.write(Path path, byte[] bytes, OpenOption... options). For example, let's write the content of the preceding ...