Package com.github.toolarium.common.util
Class ChannelUtil
java.lang.Object
com.github.toolarium.common.util.ChannelUtil
The channel util class
-
Method Summary
Modifier and TypeMethodDescriptionlongchannelCopy(InputStream src, OutputStream dest) This method copies data from the src channel and writes it to the dest channel until EOF on src.longchannelCopy(InputStream src, OutputStream dest, MessageDigest messageDigest) This method copies data from the src channel and writes it to the dest channel until EOF on src.longchannelCopy(ReadableByteChannel src, WritableByteChannel dest) This method copies data from the src channel and writes it to the dest channel until EOF on src.static ChannelUtilGet the instance
-
Method Details
-
getInstance
Get the instance- Returns:
- the instance
-
channelCopy
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 channeldest- the destination channel- Returns:
- the copied bytes
- Throws:
IOException- in case of error
-
channelCopy
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 channeldest- 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 channeldest- the destination channelmessageDigest- the message digest- Returns:
- the copied bytes
- Throws:
IOException- in case of error
-