SebastianDietrich commented on a change in pull request #281:
URL: https://github.com/apache/commons-io/pull/281#discussion_r730660676



##########
File path: src/main/java/org/apache/commons/io/IOUtils.java
##########
@@ -979,6 +981,40 @@ public static int copy(final InputStream inputStream, 
final OutputStream outputS
         return (int) count;
     }
 
+    /**
+     * Copies bytes from a {@link java.io.ByteArrayOutputStream} to a {@code 
QueueInputStream}.
+     * <p>
+     * Unlike using JDK {@link java.io.PipedInputStream} and {@link 
java.io.PipedOutputStream} for this, this
+     * solution works safely in a single thread environment.
+     * </p>
+     * <p>
+     * Example usage:
+     * </p>
+     *
+     * <pre>
+     * ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+     * outputStream.writeBytes("hello world".getBytes(UTF_8));
+     *
+     * InputStream inputStream = IOUtils.copy(outputStream);
+     * </pre>
+     *
+     * @param outputStream the {@link java.io.ByteArrayOutputStream} to read.
+     * @return the {@code QueueInputStream} filled with the content of the 
outputStream.
+     * @throws NullPointerException if the {@link 
java.io.ByteArrayOutputStream} is {@code null}.
+     * @throws IOException if an I/O error occurs.
+     * @since 2.12
+     */
+    @SuppressWarnings("resource") // streams are closed by the caller.
+    public static QueueInputStream copy(final java.io.ByteArrayOutputStream 
outputStream) throws IOException {

Review comment:
       That is not possible, since 
org.apache.commons.io.output.ByteArrayOutputStream is imported and used 
throughout IOUtils




-- 
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