提交 27073390 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix some problems with FilePathAsync.position

上级 c1dd5a5c
...@@ -147,6 +147,9 @@ class FileAsync extends FileBase { ...@@ -147,6 +147,9 @@ class FileAsync extends FileBase {
@Override @Override
public FileChannel position(long pos) throws IOException { public FileChannel position(long pos) throws IOException {
if (pos < 0) {
throw new IllegalArgumentException();
}
position = pos; position = pos;
return this; return this;
} }
...@@ -168,7 +171,7 @@ class FileAsync extends FileBase { ...@@ -168,7 +171,7 @@ class FileAsync extends FileBase {
@Override @Override
public FileChannel truncate(long newLength) throws IOException { public FileChannel truncate(long newLength) throws IOException {
channel.truncate(newLength); channel.truncate(newLength);
if (position < newLength) { if (newLength < position) {
position = newLength; position = newLength;
} }
return this; return this;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论