From d12b954177b31e8338c3001d5a0dbd8ecf7200e4 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Wed, 14 Dec 2022 18:18:26 -0800 Subject: [PATCH] 7093322: (fs spec) Files.newBufferedWriter should be clear when coding errors are detected --- src/java.base/share/classes/java/nio/file/Files.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/java.base/share/classes/java/nio/file/Files.java b/src/java.base/share/classes/java/nio/file/Files.java index 601dd99d461..682340614a6 100644 --- a/src/java.base/share/classes/java/nio/file/Files.java +++ b/src/java.base/share/classes/java/nio/file/Files.java @@ -2938,7 +2938,12 @@ public static BufferedReader newBufferedReader(Path path) throws IOException { * a size of {@code 0} if it exists. * *

The {@code Writer} methods to write text throw {@code IOException} - * if the text cannot be encoded using the specified charset. + * if the text cannot be encoded using the specified charset. Due to + * buffering, an {@code IOException} caused by an encoding error + * (unmappable-character or malformed-input) may be thrown when {@linkplain + * BufferedWriter#write(char[],int,int) writing}, {@linkplain + * BufferedWriter#flush flushing}, or {@linkplain BufferedWriter#close + * closing} the buffered writer. * * @param path * the path to the file