Skip to content
Snippets Groups Projects
Commit 82f2cd0e authored by Paul-Christian Volkmer's avatar Paul-Christian Volkmer Committed by Daniel Gerhardt
Browse files

Use try-with-resource statement to close stream on exception

parent 1a9c74c5
Branches
Tags
No related merge requests found
...@@ -230,11 +230,9 @@ public class ImageUtils { ...@@ -230,11 +230,9 @@ public class ImageUtils {
* @return The <code>byte[]</code> of the image on success, otherwise <code>null</code>. * @return The <code>byte[]</code> of the image on success, otherwise <code>null</code>.
*/ */
byte[] convertFileToByteArray(final String imageUrl) { byte[] convertFileToByteArray(final String imageUrl) {
try { try (InputStream is = new URL(imageUrl).openStream()) {
final URL url = new URL(imageUrl);
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final InputStream is = url.openStream();
final byte[] byteChunk = new byte[CHUNK_SIZE]; final byte[] byteChunk = new byte[CHUNK_SIZE];
int n; int n;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment