Yes, that is a problem with this topic. Some combinations work on some platforms but not on others. The JavaDoc API description doesn't specify clearly the combinations that should work.
If you like our products and services, please help us by posting your review here.
Connected to the target VM, address: '127.0.0.1:63393', transport: 'socket'
Disconnected from the target VM, address: '127.0.0.1:63393', transport: 'socket'
Exception in thread "main" java.lang.IllegalArgumentException: READ not allowed
at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:429)
at java.nio.file.Files.newOutputStream(Files.java:216)
at java.nio.file.Files.newBufferedWriter(Files.java:2860)
at java.nio.file.Files.newBufferedWriter(Files.java:2896)
at pl.mal.App.main(App.java:34)
Process finished with exit code 1
Path p = Paths.get("c:\\tmp\\test1\\test1.txt");
BufferedWriter br = Files.newBufferedWriter(p, Charset.forName("UTF-8")
,new OpenOption[] {StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.APPEND});
Exception in thread "main" java.lang.IllegalArgumentException: APPEND + TRUNCATE_EXISTING not allowed
at sun.nio.fs.WindowsChannelFactory.newFileChannel(WindowsChannelFactory.java:160)
at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:225)
at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434)
at java.nio.file.Files.newOutputStream(Files.java:216)
at java.nio.file.Files.newBufferedWriter(Files.java:2860)
at ocp8.practice2.T31.f3(T31.java:104)
at ocp8.practice2.T31.main(T31.java:74)