Class ChannelHelper

java.lang.Object
com.helger.io.channel.ChannelHelper

@Immutable public final class ChannelHelper extends Object
Some very basic NIO channel utility stuff.
Author:
Philip Helger
  • Method Details

    • channelCopy

      @Nonnegative public static long channelCopy(@WillNotClose @NonNull ReadableByteChannel aSrc, @WillNotClose @NonNull WritableByteChannel aDest) throws IOException
      Copy all content from the source channel to the destination channel.
      Parameters:
      aSrc - Source channel. May not be null. Is not closed after the operation.
      aDest - Destination channel. May not be null. Is not closed after the operation.
      Returns:
      The number of bytes written.
      Throws:
      IOException - In case of IO error
    • close

      public static @NonNull com.helger.base.state.ESuccess close(@Nullable Channel aChannel)
      Close the passed channel if it is not null and still open.
      Parameters:
      aChannel - The channel to be closed. May be null.
      Returns:
      ESuccess.SUCCESS if the channel was successfully closed, ESuccess.FAILURE otherwise.
    • release

      public static @NonNull com.helger.base.state.ESuccess release(@Nullable FileLock aFileLock)
      Release the passed file lock if it is not null.
      Parameters:
      aFileLock - The file lock to be released. May be null.
      Returns:
      ESuccess.SUCCESS if the lock was successfully released, ESuccess.FAILURE otherwise.