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/03/21 14:50:02 UTC
[commons-imaging] 02/02: BinaryOutputStream now subclasses FilterOutputStream instead of OutputStream and does not need to count bytes
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 b90b2fecd97240bb4d57402adbc39fdeac75920d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Mar 21 10:49:56 2023 -0400
BinaryOutputStream now subclasses FilterOutputStream instead of
OutputStream and does not need to count bytes
---
src/changes/changes.xml | 3 ++
.../commons/imaging/common/BinaryOutputStream.java | 35 ++++++----------------
2 files changed, 12 insertions(+), 26 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 47917d02..7d39572d 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -54,6 +54,9 @@ The <action> type attribute can be add,update,fix,remove.
<action issue="IMAGING-342" dev="kinow" type="fix" due-to="Glavo">
Read PNG metadata from iTXt chunk.
</action>
+ <action dev="ggregory" type="update" due-to="Gary Gregory">
+ BinaryOutputStream now subclasses FilterOutputStream instead of OutputStream and does not need to count bytes.
+ </action>
<!-- UPDATE -->
<action dev="kinow" type="update" due-to="Dependabot, Gary Gregory">
Bump actions/cache from 3.0.4 to 3.0.10 #225, #228, #239, #240.
diff --git a/src/main/java/org/apache/commons/imaging/common/BinaryOutputStream.java b/src/main/java/org/apache/commons/imaging/common/BinaryOutputStream.java
index 1d393d9a..631ddcf5 100644
--- a/src/main/java/org/apache/commons/imaging/common/BinaryOutputStream.java
+++ b/src/main/java/org/apache/commons/imaging/common/BinaryOutputStream.java
@@ -16,23 +16,23 @@
*/
package org.apache.commons.imaging.common;
+import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteOrder;
-public class BinaryOutputStream extends OutputStream {
- private final OutputStream os;
- // default byte order for Java, many file formats.
+public class BinaryOutputStream extends FilterOutputStream {
+
+ /** Default byte order for Java, many file formats. */
private ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
- private int count;
public BinaryOutputStream(final OutputStream os, final ByteOrder byteOrder) {
+ super(os);
this.byteOrder = byteOrder;
- this.os = os;
}
public BinaryOutputStream(final OutputStream os) {
- this.os = os;
+ super(os);
}
protected void setByteOrder(final ByteOrder byteOrder) {
@@ -45,34 +45,17 @@ public class BinaryOutputStream extends OutputStream {
@Override
public void write(final int i) throws IOException {
- os.write(i);
- count++;
+ super.write(i);
}
@Override
public final void write(final byte[] bytes) throws IOException {
- os.write(bytes, 0, bytes.length);
- count += bytes.length;
+ super.write(bytes, 0, bytes.length);
}
@Override
public final void write(final byte[] bytes, final int offset, final int length) throws IOException {
- os.write(bytes, offset, length);
- count += length;
- }
-
- @Override
- public void flush() throws IOException {
- os.flush();
- }
-
- @Override
- public void close() throws IOException {
- os.close();
- }
-
- public int getByteCount() {
- return count;
+ super.write(bytes, offset, length);
}
public final void write4Bytes(final int value) throws IOException {