Package com.github.toolarium.common.util
Class ChannelUtil
- java.lang.Object
-
- com.github.toolarium.common.util.ChannelUtil
-
public final class ChannelUtil extends java.lang.ObjectThe channel util class
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longchannelCopy(java.io.InputStream src, java.io.OutputStream dest)This method copies data from the src channel and writes it to the dest channel until EOF on src.longchannelCopy(java.io.InputStream src, java.io.OutputStream dest, java.security.MessageDigest messageDigest)This method copies data from the src channel and writes it to the dest channel until EOF on src.longchannelCopy(java.nio.channels.ReadableByteChannel src, java.nio.channels.WritableByteChannel dest)This method copies data from the src channel and writes it to the dest channel until EOF on src.static ChannelUtilgetInstance()Get the instance
-
-
-
Method Detail
-
getInstance
public static ChannelUtil getInstance()
Get the instance- Returns:
- the instance
-
channelCopy
public long channelCopy(java.io.InputStream src, java.io.OutputStream dest) throws java.io.IOExceptionThis 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 channeldest- the destination channel- Returns:
- the copied bytes
- Throws:
java.io.IOException- in case of error
-
channelCopy
public long channelCopy(java.nio.channels.ReadableByteChannel src, java.nio.channels.WritableByteChannel dest) throws java.io.IOExceptionThis 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 channeldest- the destination channel- Returns:
- the copied bytes
- Throws:
java.io.IOException- in case of error
-
channelCopy
public long channelCopy(java.io.InputStream src, java.io.OutputStream dest, java.security.MessageDigest messageDigest) throws java.io.IOExceptionThis 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 channeldest- the destination channelmessageDigest- the message digest- Returns:
- the copied bytes
- Throws:
java.io.IOException- in case of error
-
-