@Override public long size() throws IOException { checkOpen(); long size = 0; // will definitely either be assigned or an exception will be thrown boolean completed = false; try { if (!beginBlocking()) { return 0; // AsynchronousCloseException will be thrown } file.readLock().lockInterruptibly(); try { size = file.sizeWithoutLocking(); completed = true; } finally { file.readLock().unlock(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { endBlocking(completed); } return size; }
Thread.currentThread().interrupt(); } finally { endBlocking(completed);
@Override public int read(ByteBuffer dst, long position) throws IOException { checkNotNull(dst); Util.checkNotNegative(position, "position"); checkOpen(); checkReadable(); int read = 0; // will definitely either be assigned or an exception will be thrown // no need to synchronize here; this method does not make use of the channel's position boolean completed = false; try { if (!beginBlocking()) { return 0; // AsynchronousCloseException will be thrown } file.readLock().lockInterruptibly(); try { read = file.read(position, dst); file.updateAccessTime(); completed = true; } finally { file.readLock().unlock(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { endBlocking(completed); } return read; }
Thread.currentThread().interrupt(); } finally { endBlocking(completed);
@Override public long transferTo(long position, long count, WritableByteChannel target) throws IOException { checkNotNull(target); Util.checkNotNegative(position, "position"); Util.checkNotNegative(count, "count"); checkOpen(); checkReadable(); long transferred = 0; // will definitely either be assigned or an exception will be thrown // no need to synchronize here; this method does not make use of the channel's position boolean completed = false; try { if (!beginBlocking()) { return 0; // AsynchronousCloseException will be thrown } file.readLock().lockInterruptibly(); try { transferred = file.transferTo(position, count, target); file.updateAccessTime(); completed = true; } finally { file.readLock().unlock(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { endBlocking(completed); } return transferred; }
Thread.currentThread().interrupt(); } finally { endBlocking(completed);
@Override public FileChannel truncate(long size) throws IOException { Util.checkNotNegative(size, "size"); checkOpen(); checkWritable(); synchronized (this) { boolean completed = false; try { if (!beginBlocking()) { return this; // AsynchronousCloseException will be thrown } file.writeLock().lockInterruptibly(); try { file.truncate(size); if (position > size) { position = size; } file.updateModifiedTime(); completed = true; } finally { file.writeLock().unlock(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { endBlocking(completed); } } return this; }
Thread.currentThread().interrupt(); } finally { endBlocking(completed);
Thread.currentThread().interrupt(); } finally { endBlocking(completed); Thread.currentThread().interrupt(); } finally { endBlocking(completed);
Thread.currentThread().interrupt(); } finally { endBlocking(completed); Thread.currentThread().interrupt(); } finally { endBlocking(completed);
@Override public long size() throws IOException { checkOpen(); long size = 0; // will definitely either be assigned or an exception will be thrown boolean completed = false; try { if (!beginBlocking()) { return 0; // AsynchronousCloseException will be thrown } file.readLock().lockInterruptibly(); try { size = file.sizeWithoutLocking(); completed = true; } finally { file.readLock().unlock(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { endBlocking(completed); } return size; }
Thread.currentThread().interrupt(); } finally { endBlocking(completed);
@Override public int read(ByteBuffer dst, long position) throws IOException { checkNotNull(dst); Util.checkNotNegative(position, "position"); checkOpen(); checkReadable(); int read = 0; // will definitely either be assigned or an exception will be thrown // no need to synchronize here; this method does not make use of the channel's position boolean completed = false; try { if (!beginBlocking()) { return 0; // AsynchronousCloseException will be thrown } file.readLock().lockInterruptibly(); try { read = file.read(position, dst); file.updateAccessTime(); completed = true; } finally { file.readLock().unlock(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { endBlocking(completed); } return read; }
Thread.currentThread().interrupt(); } finally { endBlocking(completed);
Thread.currentThread().interrupt(); } finally { endBlocking(completed);
@Override public FileChannel truncate(long size) throws IOException { Util.checkNotNegative(size, "size"); checkOpen(); checkWritable(); synchronized (this) { boolean completed = false; try { if (!beginBlocking()) { return this; // AsynchronousCloseException will be thrown } file.writeLock().lockInterruptibly(); try { file.truncate(size); if (position > size) { position = size; } file.updateModifiedTime(); completed = true; } finally { file.writeLock().unlock(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { endBlocking(completed); } } return this; }
@Override public long transferTo(long position, long count, WritableByteChannel target) throws IOException { checkNotNull(target); Util.checkNotNegative(position, "position"); Util.checkNotNegative(count, "count"); checkOpen(); checkReadable(); long transferred = 0; // will definitely either be assigned or an exception will be thrown // no need to synchronize here; this method does not make use of the channel's position boolean completed = false; try { if (!beginBlocking()) { return 0; // AsynchronousCloseException will be thrown } file.readLock().lockInterruptibly(); try { transferred = file.transferTo(position, count, target); file.updateAccessTime(); completed = true; } finally { file.readLock().unlock(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { endBlocking(completed); } return transferred; }
Thread.currentThread().interrupt(); } finally { endBlocking(completed); Thread.currentThread().interrupt(); } finally { endBlocking(completed);
Thread.currentThread().interrupt(); } finally { endBlocking(completed);
Thread.currentThread().interrupt(); } finally { endBlocking(completed); Thread.currentThread().interrupt(); } finally { endBlocking(completed);