8205058: (fs) Files read/writeString should throw CharacterCodingException instead of IOException with an IllegalArgumentException as cause

Reviewed-by: sherman, alanb, lancea
This commit is contained in:
Joe Wang 2018-06-27 09:31:51 -07:00
parent 884f9db3c6
commit e5ac84c7b0
5 changed files with 80 additions and 49 deletions

View file

@ -3281,11 +3281,7 @@ public final class Files {
Objects.requireNonNull(cs);
byte[] ba = readAllBytes(path);
try {
return JLA.newStringNoRepl(ba, cs);
} catch (IllegalArgumentException e) {
throw new IOException(e);
}
return JLA.newStringNoRepl(ba, cs);
}
/**
@ -3636,12 +3632,8 @@ public final class Files {
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);
}
byte[] bytes = JLA.getBytesNoRepl(String.valueOf(csq), cs);
write(path, bytes, options);
return path;
}