In Tutorials > The Java I/O API > File Operations Basics > Releasing Resources and Catching Exceptions, "Catching Exceptions" section, the sample code creates a File object and passes it into Files.newBufferedWriter().
However, according to the Java Docs, this method takes a java.nio.file.Path object, not a java.io.File object.
Charset charset = Charset.forName("US-ASCII");
File file = ...;
String s = ...;
try (BufferedWriter writer = Files.newBufferedWriter(file, charset)) {
writer.write(s, 0, s.length());
} catch (IOException x) {
System.err.format("IOException: %s%n", x);
}
In Tutorials > The Java I/O API > File Operations Basics > Releasing Resources and Catching Exceptions, "Catching Exceptions" section, the sample code creates a
Fileobject and passes it intoFiles.newBufferedWriter().However, according to the Java Docs, this method takes a
java.nio.file.Pathobject, not ajava.io.Fileobject.