kvr000 commented on code in PR #455:
URL: https://github.com/apache/commons-compress/pull/455#discussion_r1438715949


##########
src/main/java/org/apache/commons/compress/utils/IOUtils.java:
##########
@@ -275,6 +277,49 @@ public static byte[] readRange(final ReadableByteChannel 
input, final int len) t
         return output.toByteArray();
     }
 
+    /**
+     * Writes full buffer to channel.
+     *
+     * @param channel
+     *      channel to write to
+     * @param buf
+     *      buffer to write
+     * @throws IOException
+     *      when writing fails
+     */
+    public static void writeFully(SeekableByteChannel channel, ByteBuffer buf) 
throws IOException {

Review Comment:
   The methods in `SeekableByteChannel` have `write` semantics to attempt to 
write and return as soon as the `write` is attempted.  So I wanted to avoid 
naming conflict with those and be explicit that this writes full buffer or 
fails.
   Other libraries use the same semantics, such as 
https://hadoop.apache.org/docs/stable/api/org/apache/hadoop/io/IOUtils.html#writeFully-java.nio.channels.FileChannel-java.nio.ByteBuffer-long-
   
   The example also specifies the same order of parameters which in my opinion 
makes sense - it operates on object which comes as first parameter, not really 
in a sense of source of destination.  I can amend this but it's inconsistent 
with other libraries.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to