private synchronized void reopen(ClosedChannelException e) throws IOException { if (explictlyClosed) { throw e; } if (fc.isOpen()) { // file channel has been already reopened by another thread return; } open(); }
public NioFile(File file) throws IOException { this.file = file; if (!file.exists()) { boolean created = file.createNewFile(); if (!created) { throw new IOException("Failed to create file: " + file); } } explictlyClosed = false; open(); }