Class ChannelUtil

java.lang.Object
com.github.toolarium.common.util.ChannelUtil

public final class ChannelUtil extends Object
The channel util class
  • Method Details

    • getInstance

      public static ChannelUtil getInstance()
      Get the instance
      Returns:
      the instance
    • channelCopy

      public long channelCopy(InputStream src, OutputStream dest) throws IOException
      This method copies data from the src channel and writes it to the dest channel until EOF on src. This implementation makes use of compact() on the temp buffer to pack down the data if the buffer wasn't fully drained. This may result in data copying, but minimizes system calls. It also requires a cleanup loop to make sure all the data gets sent.
      Parameters:
      src - the source channel
      dest - the destination channel
      Returns:
      the copied bytes
      Throws:
      IOException - in case of error
    • channelCopy

      public long channelCopy(ReadableByteChannel src, WritableByteChannel dest) throws IOException
      This method copies data from the src channel and writes it to the dest channel until EOF on src. This implementation makes use of compact() on the temp buffer to pack down the data if the buffer wasn't fully drained. This may result in data copying, but minimizes system calls. It also requires a cleanup loop to make sure all the data gets sent.
      Parameters:
      src - the source channel
      dest - the destination channel
      Returns:
      the copied bytes
      Throws:
      IOException - in case of error
    • channelCopy

      public long channelCopy(InputStream src, OutputStream dest, MessageDigest messageDigest) throws IOException
      This method copies data from the src channel and writes it to the dest channel until EOF on src. This implementation makes use of compact() on the temp buffer to pack down the data if the buffer wasn't fully drained. This may result in data copying, but minimizes system calls. It also requires a cleanup loop to make sure all the data gets sent.
      Parameters:
      src - the source channel
      dest - the destination channel
      messageDigest - the message digest
      Returns:
      the copied bytes
      Throws:
      IOException - in case of error