Skip to content

Commit 314607a

Browse files
committed
Using try-with-resources in setContents(InputStream)
1 parent 87928ef commit 314607a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

resources/api/src/main/java/org/jboss/forge/addon/resource/AbstractFileResource.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,14 @@ public T setContents(final InputStream data)
245245
}
246246
}
247247

248-
OutputStream out = getFileOperations().createOutputStream(file);
249-
try
248+
try (OutputStream out = getResourceOutputStream())
250249
{
251250
Streams.write(data, out);
251+
out.flush();
252252
}
253253
finally
254254
{
255255
Streams.closeQuietly(data);
256-
out.flush();
257-
Streams.closeQuietly(out);
258256
}
259257
}
260258
catch (IOException e)

0 commit comments

Comments
 (0)