You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/05/14 16:24:25 UTC
[commons-imaging] 14/14: Use try-with-resources
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git
commit cd2adad958febd358ee9af8964eee7f9d189825f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun May 14 12:23:59 2023 -0400
Use try-with-resources
---
.../imaging/formats/tiff/write/TiffImageWriterLossless.java | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java b/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java
index 36951633..4e3e6600 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java
@@ -295,9 +295,10 @@ public class TiffImageWriterLossless extends TiffImageWriterBase {
// copy old data (including maker notes, etc.)
System.arraycopy(exifBytes, 0, output, 0, Math.min(exifBytes.length, output.length));
- final BufferOutputStream headerStream = new BufferOutputStream(output, 0);
- final BinaryOutputStream headerBinaryStream = BinaryOutputStream.create(headerStream, byteOrder);
- writeImageFileHeader(headerBinaryStream, rootDirectory.getOffset());
+ try (BufferOutputStream headerStream = new BufferOutputStream(output, 0);
+ BinaryOutputStream headerBinaryStream = BinaryOutputStream.create(headerStream, byteOrder)) {
+ writeImageFileHeader(headerBinaryStream, rootDirectory.getOffset());
+ }
// zero out the parsed pieces of old exif segment, in case we don't
// overwrite them.
@@ -308,8 +309,8 @@ public class TiffImageWriterLossless extends TiffImageWriterBase {
// write in the new items
for (final TiffOutputItem outputItem : outputItems) {
- try (BinaryOutputStream bos = BinaryOutputStream.create(
- new BufferOutputStream(output, (int) outputItem.getOffset()), byteOrder)) {
+ try (BinaryOutputStream bos = BinaryOutputStream
+ .create(new BufferOutputStream(output, (int) outputItem.getOffset()), byteOrder)) {
outputItem.writeItem(bos);
}
}