/** * Performs a protected {@link FileChannel#read(ByteBuffer, long)} call. */ public int read(ByteBuffer buf, long offset) throws IOException { while (true) { try { return fc.read(buf, offset); } catch (ClosedByInterruptException e) { throw e; } catch (ClosedChannelException e) { reopen(e); } } }
/** * Performs a protected {@link FileChannel#force(boolean)} call. */ public void force(boolean metaData) throws IOException { while (true) { try { fc.force(metaData); return; } catch (ClosedByInterruptException e) { throw e; } catch (ClosedChannelException e) { reopen(e); } } }
/** * Performs a protected {@link FileChannel#size()} call. */ public long size() throws IOException { while (true) { try { return fc.size(); } catch (ClosedByInterruptException e) { throw e; } catch (ClosedChannelException e) { reopen(e); } } }
/** * Performs a protected {@link FileChannel#write(ByteBuffer, long)} call. */ public int write(ByteBuffer buf, long offset) throws IOException { while (true) { try { return fc.write(buf, offset); } catch (ClosedByInterruptException e) { throw e; } catch (ClosedChannelException e) { reopen(e); } } }
/** * Performs a protected {@link FileChannel#truncate(long)} call. */ public void truncate(long size) throws IOException { while (true) { try { fc.truncate(size); return; } catch (ClosedByInterruptException e) { throw e; } catch (ClosedChannelException e) { reopen(e); } } }
/** * Performs a protected * {@link FileChannel#transferTo(long, long, WritableByteChannel)} call. */ public long transferTo(long position, long count, WritableByteChannel target) throws IOException { while (true) { try { return fc.transferTo(position, count, target); } catch (ClosedByInterruptException e) { throw e; } catch (ClosedChannelException e) { reopen(e); } } }