Skip to content
Snippets Groups Projects
Commit b542ec57 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

Cherry-picked from GH-51.
parent 1a9c74c5
No related merge requests found
......@@ -230,11 +230,9 @@ public class ImageUtils {
* @return The <code>byte[]</code> of the image on success, otherwise <code>null</code>.
*/
byte[] convertFileToByteArray(final String imageUrl) {
try {
final URL url = new URL(imageUrl);
try (InputStream is = new URL(imageUrl).openStream()) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final InputStream is = url.openStream();
final byte[] byteChunk = new byte[CHUNK_SIZE];
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