Skip to content

Commit

Permalink
use stream instead of iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Feb 28, 2024
1 parent 0a92598 commit 819991f
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/main/java/org/cryptomator/cryptofs/fh/ChunkIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,11 @@ int write(ByteBuffer src, long position) throws IOException {
}

private FileChannel getReadableChannel() {
Iterator<FileChannel> iter = readableChannels.iterator();
if (iter.hasNext()) {
return iter.next();
} else {
throw new NonReadableChannelException();
}
return readableChannels.stream().findFirst().orElseThrow(NonReadableChannelException::new);
}

private FileChannel getWritableChannel() {
Iterator<FileChannel> iter = writableChannels.iterator();
if (iter.hasNext()) {
return iter.next();
} else {
throw new NonWritableChannelException();
}
return writableChannels.stream().findFirst().orElseThrow(NonWritableChannelException::new);
}

}

0 comments on commit 819991f

Please sign in to comment.