diff --git a/src/main/java/org/cryptomator/cryptofs/fh/ChunkIO.java b/src/main/java/org/cryptomator/cryptofs/fh/ChunkIO.java index 8ec707f8..e1e73c63 100644 --- a/src/main/java/org/cryptomator/cryptofs/fh/ChunkIO.java +++ b/src/main/java/org/cryptomator/cryptofs/fh/ChunkIO.java @@ -52,21 +52,11 @@ int write(ByteBuffer src, long position) throws IOException { } private FileChannel getReadableChannel() { - Iterator iter = readableChannels.iterator(); - if (iter.hasNext()) { - return iter.next(); - } else { - throw new NonReadableChannelException(); - } + return readableChannels.stream().findFirst().orElseThrow(NonReadableChannelException::new); } private FileChannel getWritableChannel() { - Iterator iter = writableChannels.iterator(); - if (iter.hasNext()) { - return iter.next(); - } else { - throw new NonWritableChannelException(); - } + return writableChannels.stream().findFirst().orElseThrow(NonWritableChannelException::new); } }