Sort new method.
@@ -980,39 +980,6 @@ 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(StandardCharsets.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 {
- Objects.requireNonNull(outputStream, "outputStream");
-
- final QueueInputStream in = new QueueInputStream();
- outputStream.writeTo(in.newQueueOutputStream());
-
- return in;
- }
-
/**
* Copies bytes from an {@code InputStream} to an {@code OutputStream} using an internal buffer of the
* given size.
@@ -1112,6 +1079,39 @@ public static void copy(final InputStream input, final Writer writer, final Stri
copy(input, writer, Charsets.toCharset(inputCharsetName));
}
+ /**
+ * 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(StandardCharsets.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 {
+ Objects.requireNonNull(outputStream, "outputStream");
+
+ final QueueInputStream in = new QueueInputStream();
+ outputStream.writeTo(in.newQueueOutputStream());
+
+ return in;
+ }
+
/**
* Copies chars from a {@code Reader} to a {@code Appendable}.
* <p>
