Example usage for java.nio.channels.spi AbstractInterruptibleChannel close

List of usage examples for java.nio.channels.spi AbstractInterruptibleChannel close

Introduction

In this page you can find the example usage for java.nio.channels.spi AbstractInterruptibleChannel close.

Prototype

public final void close() throws IOException 

Source Link

Document

Closes this channel.

Usage

From source file:dk.clanie.io.IOUtil.java

/**
 * Closes nio Channels.//from ww  w. j ava2s  . c om
 * <p>
 * Suppresses errors - if an Exception occurs it will be logged, but
 * otherwise silently ignored.
 * </p>
 * <p>
 * Nulls in the channels argument are ignored.
 * </p>
 * 
 * @param channels
 *            - AbstractInterruptibleChannels to close.
 */
public static void closeChannels(AbstractInterruptibleChannel... channels) {
    for (AbstractInterruptibleChannel channel : channels) {
        if (channel == null)
            continue;
        try {
            channel.close();
        } catch (Exception e) {
            log.error(FAILED_TO_CLOSE_CHANNEL, e);
        }
    }
}