< prev index next >
src/java.base/share/classes/java/nio/file/Files.java
Print this page
*** 3277,3291 ****
public static String readString(Path path, Charset cs) throws IOException {
Objects.requireNonNull(path);
Objects.requireNonNull(cs);
byte[] ba = readAllBytes(path);
- try {
return JLA.newStringNoRepl(ba, cs);
- } catch (IllegalArgumentException e) {
- throw new IOException(e);
- }
}
/**
* Read all lines from a file. This method ensures that the file is
* closed when all bytes have been read or an I/O error, or other runtime
--- 3277,3287 ----
*** 3632,3647 ****
// ensure the text is not null before opening file
Objects.requireNonNull(path);
Objects.requireNonNull(csq);
Objects.requireNonNull(cs);
- try {
byte[] bytes = JLA.getBytesNoRepl(String.valueOf(csq), cs);
write(path, bytes, options);
- } catch (IllegalArgumentException e) {
- throw new IOException(e);
- }
return path;
}
// -- Stream APIs --
--- 3628,3639 ----
< prev index next >