|
45 | 45 | import java.nio.charset.Charset; |
46 | 46 | import java.nio.file.Files; |
47 | 47 | import java.util.ArrayList; |
| 48 | +import java.util.Arrays; |
48 | 49 | import java.util.Collection; |
49 | 50 | import java.util.List; |
50 | 51 | import java.util.Objects; |
@@ -521,11 +522,8 @@ public static void closeQuietly(final Closeable closeable) { |
521 | 522 | * @see Throwable#addSuppressed(java.lang.Throwable) |
522 | 523 | */ |
523 | 524 | public static void closeQuietly(final Closeable... closeables) { |
524 | | - if (closeables == null) { |
525 | | - return; |
526 | | - } |
527 | | - for (final Closeable closeable : closeables) { |
528 | | - closeQuietly(closeable); |
| 525 | + if (closeables != null) { |
| 526 | + Arrays.stream(closeables).forEach(IOUtils::closeQuietly); |
529 | 527 | } |
530 | 528 | } |
531 | 529 |
|
@@ -1105,10 +1103,8 @@ public static void copy(final InputStream input, final Writer writer, final Stri |
1105 | 1103 | @SuppressWarnings("resource") // streams are closed by the caller. |
1106 | 1104 | public static QueueInputStream copy(final java.io.ByteArrayOutputStream outputStream) throws IOException { |
1107 | 1105 | Objects.requireNonNull(outputStream, "outputStream"); |
1108 | | - |
1109 | 1106 | final QueueInputStream in = new QueueInputStream(); |
1110 | 1107 | outputStream.writeTo(in.newQueueOutputStream()); |
1111 | | - |
1112 | 1108 | return in; |
1113 | 1109 | } |
1114 | 1110 |
|
@@ -2198,11 +2194,9 @@ public static URL resourceToURL(final String name, final ClassLoader classLoader |
2198 | 2194 | // What about the thread context class loader? |
2199 | 2195 | // What about the system class loader? |
2200 | 2196 | final URL resource = classLoader == null ? IOUtils.class.getResource(name) : classLoader.getResource(name); |
2201 | | - |
2202 | 2197 | if (resource == null) { |
2203 | 2198 | throw new IOException("Resource not found: " + name); |
2204 | 2199 | } |
2205 | | - |
2206 | 2200 | return resource; |
2207 | 2201 | } |
2208 | 2202 |
|
@@ -2559,11 +2553,9 @@ public static byte[] toByteArray(final InputStream input, final int size) throws |
2559 | 2553 | * @since 2.1 |
2560 | 2554 | */ |
2561 | 2555 | public static byte[] toByteArray(final InputStream input, final long size) throws IOException { |
2562 | | - |
2563 | 2556 | if (size > Integer.MAX_VALUE) { |
2564 | 2557 | throw new IllegalArgumentException("Size cannot be greater than Integer max value: " + size); |
2565 | 2558 | } |
2566 | | - |
2567 | 2559 | return toByteArray(input, (int) size); |
2568 | 2560 | } |
2569 | 2561 |
|
@@ -2873,8 +2865,7 @@ public static InputStream toInputStream(final String input, final Charset charse |
2873 | 2865 | * @since 1.1 |
2874 | 2866 | */ |
2875 | 2867 | public static InputStream toInputStream(final String input, final String charsetName) { |
2876 | | - final byte[] bytes = input.getBytes(Charsets.toCharset(charsetName)); |
2877 | | - return new ByteArrayInputStream(bytes); |
| 2868 | + return new ByteArrayInputStream(input.getBytes(Charsets.toCharset(charsetName))); |
2878 | 2869 | } |
2879 | 2870 |
|
2880 | 2871 | /** |
@@ -3662,7 +3653,6 @@ public static Writer writer(final Appendable appendable) { |
3662 | 3653 | * Instances should NOT be constructed in standard programming. |
3663 | 3654 | */ |
3664 | 3655 | public IOUtils() { //NOSONAR |
3665 | | - |
3666 | 3656 | } |
3667 | 3657 |
|
3668 | 3658 | } |
0 commit comments