Code example for FileChannel

Methods: isOpen

0
        }); 
    } 
 
    private synchronized void shutdownHook() { 
        try { 
            if (mChannel.isOpen()) {
                writeBuffer(); 
            } 
        } catch (IOException e) {
            e.printStackTrace();
        } 
        mShutdownHookExecuted = true;
    } 
 
    private void writeBuffer() throws IOException { 
        mBuffer.flip();
        mChannel.write(mBuffer);
        while (mBuffer.hasRemaining()) {
            Thread.yield();
            mChannel.write(mBuffer);
        }