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 2025/09/03 11:54:29 UTC

(commons-io) branch master updated (bb0304cbe -> c7e53f772)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


    from bb0304cbe Bump actions/dependency-review-action from 4.7.2 to 4.7.3 (#775)
     new 860de720c Don't check for size twice
     new c7e53f772 Javadoc

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/commons/io/EndianUtils.java    | 62 +++++++++++-----------
 src/main/java/org/apache/commons/io/IOUtils.java   |  5 +-
 .../commons/io/input/SwappedDataInputStream.java   |  2 +-
 3 files changed, 33 insertions(+), 36 deletions(-)


(commons-io) 01/02: Don't check for size twice

Posted by gg...@apache.org.
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-io.git

commit 860de720c663776d7b9de091e8699f6276950169
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Mon Sep 1 15:39:15 2025 -0400

    Don't check for size twice
    
    Javadoc
---
 src/main/java/org/apache/commons/io/IOUtils.java | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/IOUtils.java b/src/main/java/org/apache/commons/io/IOUtils.java
index b9b7b63ab..05ff9e94c 100644
--- a/src/main/java/org/apache/commons/io/IOUtils.java
+++ b/src/main/java/org/apache/commons/io/IOUtils.java
@@ -2671,9 +2671,6 @@ public static byte[] toByteArray(final InputStream inputStream) throws IOExcepti
      */
     @SuppressWarnings("resource")
     public static byte[] toByteArray(final InputStream input, final int size) throws IOException {
-        if (size == 0) {
-            return EMPTY_BYTE_ARRAY;
-        }
         return toByteArray(Objects.requireNonNull(input, "input")::read, size);
     }
 
@@ -2703,7 +2700,7 @@ public static byte[] toByteArray(final InputStream input, final long size) throw
     /**
      * Gets the contents of an input as a {@code byte[]}.
      *
-     * @param input the input to read.
+     * @param input the input to read, not null.
      * @param size the size of the input to read, where 0 &lt; {@code size} &lt;= length of input.
      * @return byte [] of length {@code size}.
      * @throws IOException if an I/O error occurs or input length is smaller than parameter {@code size}.


(commons-io) 02/02: Javadoc

Posted by gg...@apache.org.
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-io.git

commit c7e53f772f6fc1e2d6d3bb7477a48a9123b9686e
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Wed Sep 3 07:54:23 2025 -0400

    Javadoc
---
 .../java/org/apache/commons/io/EndianUtils.java    | 62 +++++++++++-----------
 .../commons/io/input/SwappedDataInputStream.java   |  2 +-
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/EndianUtils.java b/src/main/java/org/apache/commons/io/EndianUtils.java
index 9fa1913c7..6cac2bab5 100644
--- a/src/main/java/org/apache/commons/io/EndianUtils.java
+++ b/src/main/java/org/apache/commons/io/EndianUtils.java
@@ -26,7 +26,7 @@
 /**
  * Helps with reading and writing primitive numeric types ({@code short},
  * {@code int}, {@code long}, {@code float}, and {@code double}) that are
- * encoded in little endian using two's complement or unsigned representations.
+ * encoded in little-endian using two's complement or unsigned representations.
  * <p>
  * Different computer architectures have different conventions for
  * byte ordering. In "Little Endian" architectures (e.g. X86),
@@ -36,7 +36,7 @@
  * Most methods and classes throughout Java &mdash; e.g. {@code DataInputStream} and
  * {@code Double.longBitsToDouble()} &mdash; assume data is laid out
  * in big endian order with the most significant byte first.
- * The methods in this class read and write data in little endian order,
+ * The methods in this class read and write data in little-endian order,
  * generally by reversing the bytes and then using the
  * regular Java methods to convert the swapped bytes to a primitive type.
  * </p>
@@ -63,7 +63,7 @@ private static int read(final InputStream input) throws IOException {
     }
 
     /**
-     * Reads a little endian {@code double} value from a byte array at a given offset.
+     * Reads a little-endian {@code double} value from a byte array at a given offset.
      *
      * @param data source byte array
      * @param offset starting offset in the byte array
@@ -75,7 +75,7 @@ public static double readSwappedDouble(final byte[] data, final int offset) {
     }
 
     /**
-     * Reads a little endian {@code double} value from an InputStream.
+     * Reads a little-endian {@code double} value from an InputStream.
      *
      * @param input source InputStream
      * @return the value just read
@@ -86,7 +86,7 @@ public static double readSwappedDouble(final InputStream input) throws IOExcepti
     }
 
     /**
-     * Reads a little endian {@code float} value from a byte array at a given offset.
+     * Reads a little-endian {@code float} value from a byte array at a given offset.
      *
      * @param data source byte array
      * @param offset starting offset in the byte array
@@ -98,7 +98,7 @@ public static float readSwappedFloat(final byte[] data, final int offset) {
     }
 
     /**
-     * Reads a little endian {@code float} value from an InputStream.
+     * Reads a little-endian {@code float} value from an InputStream.
      *
      * @param input source InputStream
      * @return the value just read
@@ -109,7 +109,7 @@ public static float readSwappedFloat(final InputStream input) throws IOException
     }
 
     /**
-     * Reads a little endian {@code int} value from a byte array at a given offset.
+     * Reads a little-endian {@code int} value from a byte array at a given offset.
      *
      * @param data source byte array
      * @param offset starting offset in the byte array
@@ -125,7 +125,7 @@ public static int readSwappedInteger(final byte[] data, final int offset) {
     }
 
     /**
-     * Reads a little endian {@code int} value from an InputStream.
+     * Reads a little-endian {@code int} value from an InputStream.
      *
      * @param input source InputStream
      * @return the value just read
@@ -140,7 +140,7 @@ public static int readSwappedInteger(final InputStream input) throws IOException
     }
 
     /**
-     * Reads a little endian {@code long} value from a byte array at a given offset.
+     * Reads a little-endian {@code long} value from a byte array at a given offset.
      *
      * @param data source byte array
      * @param offset starting offset in the byte array
@@ -155,7 +155,7 @@ public static long readSwappedLong(final byte[] data, final int offset) {
     }
 
     /**
-     * Reads a little endian {@code long} value from an InputStream.
+     * Reads a little-endian {@code long} value from an InputStream.
      *
      * @param input source InputStream
      * @return the value just read
@@ -170,7 +170,7 @@ public static long readSwappedLong(final InputStream input) throws IOException {
     }
 
     /**
-     * Reads a little endian {@code short} value from a byte array at a given offset.
+     * Reads a little-endian {@code short} value from a byte array at a given offset.
      *
      * @param data source byte array
      * @param offset starting offset in the byte array
@@ -183,7 +183,7 @@ public static short readSwappedShort(final byte[] data, final int offset) {
     }
 
     /**
-     * Reads a little endian {@code short} value from an InputStream.
+     * Reads a little-endian {@code short} value from an InputStream.
      *
      * @param input source InputStream
      * @return the value just read
@@ -194,7 +194,7 @@ public static short readSwappedShort(final InputStream input) throws IOException
     }
 
     /**
-     * Reads a little endian unsigned integer (32-bit) value from a byte array at a given
+     * Reads a little-endian unsigned integer (32-bit) value from a byte array at a given
      * offset.
      *
      * @param data source byte array
@@ -212,7 +212,7 @@ public static long readSwappedUnsignedInteger(final byte[] data, final int offse
     }
 
     /**
-     * Reads a little endian unsigned integer (32-bit) from an InputStream.
+     * Reads a little-endian unsigned integer (32-bit) from an InputStream.
      *
      * @param input source InputStream
      * @return the value just read
@@ -229,7 +229,7 @@ public static long readSwappedUnsignedInteger(final InputStream input) throws IO
     }
 
     /**
-     * Reads an unsigned short (16-bit) value from a byte array in little endian order at a given
+     * Reads an unsigned short (16-bit) value from a byte array in little-endian order at a given
      * offset.
      *
      * @param data source byte array
@@ -243,7 +243,7 @@ public static int readSwappedUnsignedShort(final byte[] data, final int offset)
     }
 
     /**
-     * Reads an unsigned short (16-bit) from an InputStream in little endian order.
+     * Reads an unsigned short (16-bit) from an InputStream in little-endian order.
      *
      * @param input source InputStream
      * @return the value just read
@@ -257,7 +257,7 @@ public static int readSwappedUnsignedShort(final InputStream input) throws IOExc
     }
 
     /**
-     * Converts a {@code double} value from big endian to little endian
+     * Converts a {@code double} value from big endian to little-endian
      * and vice versa. That is, it converts the {@code double} to bytes,
      * reverses the bytes, and then reinterprets those bytes as a new {@code double}.
      * This can be useful if you have a number that was read from the
@@ -271,7 +271,7 @@ public static double swapDouble(final double value) {
     }
 
     /**
-     * Converts a {@code float} value from big endian to little endian and vice versa.
+     * Converts a {@code float} value from big endian to little-endian and vice versa.
      *
      * @param value value to convert
      * @return the converted value
@@ -281,7 +281,7 @@ public static float swapFloat(final float value) {
     }
 
     /**
-     * Converts an {@code int} value from big endian to little endian and vice versa.
+     * Converts an {@code int} value from big endian to little-endian and vice versa.
      *
      * @param value value to convert
      * @return the converted value
@@ -295,7 +295,7 @@ public static int swapInteger(final int value) {
     }
 
     /**
-     * Converts a {@code long} value from big endian to little endian and vice versa.
+     * Converts a {@code long} value from big endian to little-endian and vice versa.
      *
      * @param value value to convert
      * @return the converted value
@@ -313,7 +313,7 @@ public static long swapLong(final long value) {
     }
 
     /**
-     * Converts a {@code short} value from big endian to little endian and vice versa.
+     * Converts a {@code short} value from big endian to little-endian and vice versa.
      *
      * @param value value to convert
      * @return the converted value
@@ -338,7 +338,7 @@ private static void validateByteArrayOffset(final byte[] data, final int offset,
     }
 
     /**
-     * Writes the 8 bytes of a {@code double} to a byte array at a given offset in little endian order.
+     * Writes the 8 bytes of a {@code double} to a byte array at a given offset in little-endian order.
      *
      * @param data target byte array
      * @param offset starting offset in the byte array
@@ -350,7 +350,7 @@ public static void writeSwappedDouble(final byte[] data, final int offset, final
     }
 
     /**
-     * Writes the 8 bytes of a {@code double} to an output stream in little endian order.
+     * Writes the 8 bytes of a {@code double} to an output stream in little-endian order.
      *
      * @param output target OutputStream
      * @param value value to write
@@ -361,7 +361,7 @@ public static void writeSwappedDouble(final OutputStream output, final double va
     }
 
     /**
-     * Writes the 4 bytes of a {@code float} to a byte array at a given offset in little endian order.
+     * Writes the 4 bytes of a {@code float} to a byte array at a given offset in little-endian order.
      *
      * @param data target byte array
      * @param offset starting offset in the byte array
@@ -373,7 +373,7 @@ public static void writeSwappedFloat(final byte[] data, final int offset, final
     }
 
     /**
-     * Writes the 4 bytes of a {@code float} to an output stream in little endian order.
+     * Writes the 4 bytes of a {@code float} to an output stream in little-endian order.
      *
      * @param output target OutputStream
      * @param value value to write
@@ -384,7 +384,7 @@ public static void writeSwappedFloat(final OutputStream output, final float valu
     }
 
     /**
-     * Writes the 4 bytes of an {@code int} to a byte array at a given offset in little endian order.
+     * Writes the 4 bytes of an {@code int} to a byte array at a given offset in little-endian order.
      *
      * @param data target byte array
      * @param offset starting offset in the byte array
@@ -400,7 +400,7 @@ public static void writeSwappedInteger(final byte[] data, final int offset, fina
     }
 
     /**
-     * Writes the 4 bytes of an {@code int} to an output stream in little endian order.
+     * Writes the 4 bytes of an {@code int} to an output stream in little-endian order.
      *
      * @param output target OutputStream
      * @param value value to write
@@ -414,7 +414,7 @@ public static void writeSwappedInteger(final OutputStream output, final int valu
     }
 
     /**
-     * Writes the 8 bytes of a {@code long} to a byte array at a given offset in little endian order.
+     * Writes the 8 bytes of a {@code long} to a byte array at a given offset in little-endian order.
      *
      * @param data target byte array
      * @param offset starting offset in the byte array
@@ -434,7 +434,7 @@ public static void writeSwappedLong(final byte[] data, final int offset, final l
     }
 
     /**
-     * Writes the 8 bytes of a {@code long} to an output stream in little endian order.
+     * Writes the 8 bytes of a {@code long} to an output stream in little-endian order.
      *
      * @param output target OutputStream
      * @param value value to write
@@ -452,7 +452,7 @@ public static void writeSwappedLong(final OutputStream output, final long value)
     }
 
     /**
-     * Writes the 2 bytes of a {@code short} to a byte array at a given offset in little endian order.
+     * Writes the 2 bytes of a {@code short} to a byte array at a given offset in little-endian order.
      *
      * @param data target byte array
      * @param offset starting offset in the byte array
@@ -466,7 +466,7 @@ public static void writeSwappedShort(final byte[] data, final int offset, final
     }
 
     /**
-     * Writes the 2 bytes of a {@code short} to an output stream using little endian encoding.
+     * Writes the 2 bytes of a {@code short} to an output stream using little-endian encoding.
      *
      * @param output target OutputStream
      * @param value value to write
diff --git a/src/main/java/org/apache/commons/io/input/SwappedDataInputStream.java b/src/main/java/org/apache/commons/io/input/SwappedDataInputStream.java
index d35a2f5c3..a901ec6bc 100644
--- a/src/main/java/org/apache/commons/io/input/SwappedDataInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/SwappedDataInputStream.java
@@ -68,7 +68,7 @@ public byte readByte() throws IOException, EOFException {
     }
 
     /**
-     * Reads a 2 byte, unsigned, little endian UTF-16 code point.
+     * Reads a 2 byte, unsigned, little-endian UTF-16 code point.
      *
      * @return the UTF-16 code point read or -1 if the end of stream
      * @throws IOException if an I/O error occurs.