提交 75e64e31 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix FileDisk.truncate() for Java 9 and later versions

Fix suggested by Noel Grandin
上级 00e46bf6
...@@ -436,9 +436,11 @@ class FileDisk extends FileBase { ...@@ -436,9 +436,11 @@ class FileDisk extends FileBase {
if (readOnly) { if (readOnly) {
throw new NonWritableChannelException(); throw new NonWritableChannelException();
} }
if (newLength < file.length()) { /*
file.setLength(newLength); * RandomAccessFile.setLength() does not always work here since Java 9 for
} * unknown reason so use FileChannel.truncate().
*/
file.getChannel().truncate(newLength);
return this; return this;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论