Skip to content

Commit 121db29

Browse files
committed
2 parents 8342fca + 2780f18 commit 121db29

File tree

12 files changed

+51
-17
lines changed

12 files changed

+51
-17
lines changed

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<modelVersion>4.0.0</modelVersion>
2525
<groupId>commons-io</groupId>
2626
<artifactId>commons-io</artifactId>
27-
<version>2.20.1-SNAPSHOT</version>
27+
<version>2.21.0-SNAPSHOT</version>
2828
<name>Apache Commons IO</name>
2929
<inceptionYear>2002</inceptionYear>
3030
<description>
@@ -47,7 +47,7 @@ file comparators, endian transformation classes, and much more.
4747
<connection>scm:git:https://gitbox.apache.org/repos/asf/commons-io.git</connection>
4848
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/commons-io.git</developerConnection>
4949
<url>https://gitbox.apache.org/repos/asf?p=commons-io.git</url>
50-
<tag>rel/commons-io-2.20.0</tag>
50+
<tag>rel/commons-io-2.21.0</tag>
5151
</scm>
5252
<ciManagement>
5353
<system>GitHub</system>
@@ -115,9 +115,9 @@ file comparators, endian transformation classes, and much more.
115115
<commons.componentid>io</commons.componentid>
116116
<commons.module.name>org.apache.commons.io</commons.module.name>
117117
<commons.rc.version>RC1</commons.rc.version>
118-
<commons.bc.version>2.19.0</commons.bc.version>
119-
<commons.release.version>2.20.0</commons.release.version>
120-
<commons.release.next>2.20.1</commons.release.next>
118+
<commons.bc.version>2.20.0</commons.bc.version>
119+
<commons.release.version>2.21.0</commons.release.version>
120+
<commons.release.next>2.21.1</commons.release.next>
121121
<!-- project.build.outputTimestamp is managed by Maven plugins, see https://maven.apache.org/guides/mini/guide-reproducible-builds.html -->
122122
<project.build.outputTimestamp>2025-07-18T21:12:04Z</project.build.outputTimestamp>
123123
<commons.release.desc>(requires Java 8)</commons.release.desc>

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ The <action> type attribute can be add,update,fix,remove.
5050
<action type="fix" dev="ggregory" due-to="Gary Gregory">When testing on Java 21 and up, enable -XX:+EnableDynamicAgentLoading.</action>
5151
<action type="fix" dev="ggregory" due-to="Gary Gregory">When testing on Java 24 and up, don't fail FileUtilsListFilesTest for a different behavior in the JRE.</action>
5252
<!-- ADD -->
53+
<action dev="ggregory" type="add" due-to="strangelookingnerd, Gary Gregory">FileUtils#byteCountToDisplaySize() supports Zettabyte, Yottabyte, Ronnabyte and Quettabyte #763.</action>
54+
<action dev="ggregory" type="add" due-to="strangelookingnerd, Gary Gregory">Add org.apache.commons.io.FileUtils.ONE_RB #763.</action>
55+
<action dev="ggregory" type="add" due-to="strangelookingnerd, Gary Gregory">Add org.apache.commons.io.FileUtils.ONE_QB #763.</action>
5356
<!-- UPDATE -->
5457
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-codec:commons-codec from 1.18.0 to 1.19.0.</action>
5558
</release>

src/main/java/org/apache/commons/io/FileUtils.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,27 @@ public class FileUtils {
194194
/**
195195
* The number of bytes in a zettabyte.
196196
*/
197-
public static final BigInteger ONE_ZB = BigInteger.valueOf(ONE_KB).multiply(BigInteger.valueOf(ONE_EB));
197+
public static final BigInteger ONE_ZB = ONE_KB_BI.multiply(ONE_EB_BI);
198198

199199
/**
200200
* The number of bytes in a yottabyte.
201201
*/
202202
public static final BigInteger ONE_YB = ONE_KB_BI.multiply(ONE_ZB);
203203

204+
/**
205+
* The number of bytes in a ronnabyte.
206+
*
207+
* @since 2.21.0
208+
*/
209+
public static final BigInteger ONE_RB = ONE_KB_BI.multiply(ONE_YB);
210+
211+
/**
212+
* The number of bytes in a quettabyte.
213+
*
214+
* @since 2.21.0
215+
*/
216+
public static final BigInteger ONE_QB = ONE_KB_BI.multiply(ONE_RB);
217+
204218
/**
205219
* An empty array of type {@link File}.
206220
*/
@@ -217,7 +231,7 @@ public class FileUtils {
217231
* </p>
218232
*
219233
* @param size the number of bytes
220-
* @return a human-readable display value (includes units - EB, PB, TB, GB, MB, KB or bytes)
234+
* @return a human-readable display value (includes units - QB, RB, YB, ZB, EB, PB, TB, GB, MB, KB or bytes)
221235
* @throws NullPointerException if the given {@link BigInteger} is {@code null}.
222236
* @see <a href="https://issues.apache.org/jira/browse/IO-226">IO-226 - should the rounding be changed?</a>
223237
* @since 2.4
@@ -227,7 +241,15 @@ public static String byteCountToDisplaySize(final BigInteger size) {
227241
Objects.requireNonNull(size, "size");
228242
final String displaySize;
229243

230-
if (size.divide(ONE_EB_BI).compareTo(BigInteger.ZERO) > 0) {
244+
if (size.divide(ONE_QB).compareTo(BigInteger.ZERO) > 0) {
245+
displaySize = size.divide(ONE_QB) + " QB";
246+
} else if (size.divide(ONE_RB).compareTo(BigInteger.ZERO) > 0) {
247+
displaySize = size.divide(ONE_RB) + " RB";
248+
} else if (size.divide(ONE_YB).compareTo(BigInteger.ZERO) > 0) {
249+
displaySize = size.divide(ONE_YB) + " YB";
250+
} else if (size.divide(ONE_ZB).compareTo(BigInteger.ZERO) > 0) {
251+
displaySize = size.divide(ONE_ZB) + " ZB";
252+
} else if (size.divide(ONE_EB_BI).compareTo(BigInteger.ZERO) > 0) {
231253
displaySize = size.divide(ONE_EB_BI) + " EB";
232254
} else if (size.divide(ONE_PB_BI).compareTo(BigInteger.ZERO) > 0) {
233255
displaySize = size.divide(ONE_PB_BI) + " PB";

src/test/java/org/apache/commons/io/EndianUtilsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void testEOFException() {
4444
}
4545

4646
@Test
47-
void testInvalidOffset() throws IOException {
47+
void testInvalidOffset() {
4848
final byte[] bytes = {};
4949

5050
assertThrows(IllegalArgumentException.class, () -> EndianUtils.readSwappedInteger(bytes, 0));

src/test/java/org/apache/commons/io/FileUtilsTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,10 @@ void testByteCountToDisplaySizeBigInteger() {
370370
final BigInteger TB1 = GB1.multiply(KB1);
371371
final BigInteger PB1 = TB1.multiply(KB1);
372372
final BigInteger EB1 = PB1.multiply(KB1);
373+
final BigInteger ZB1 = EB1.multiply(KB1);
374+
final BigInteger YB1 = ZB1.multiply(KB1);
375+
final BigInteger RB1 = YB1.multiply(KB1);
376+
final BigInteger QB1 = RB1.multiply(KB1);
373377
assertEquals("0 bytes", FileUtils.byteCountToDisplaySize(BigInteger.ZERO));
374378
assertEquals("1 bytes", FileUtils.byteCountToDisplaySize(BigInteger.ONE));
375379
assertEquals("1023 bytes", FileUtils.byteCountToDisplaySize(b1023));
@@ -386,6 +390,10 @@ void testByteCountToDisplaySizeBigInteger() {
386390
assertEquals("1 TB", FileUtils.byteCountToDisplaySize(TB1));
387391
assertEquals("1 PB", FileUtils.byteCountToDisplaySize(PB1));
388392
assertEquals("1 EB", FileUtils.byteCountToDisplaySize(EB1));
393+
assertEquals("1 ZB", FileUtils.byteCountToDisplaySize(ZB1));
394+
assertEquals("1 YB", FileUtils.byteCountToDisplaySize(YB1));
395+
assertEquals("1 RB", FileUtils.byteCountToDisplaySize(RB1));
396+
assertEquals("1 QB", FileUtils.byteCountToDisplaySize(QB1));
389397
assertEquals("7 EB", FileUtils.byteCountToDisplaySize(Long.MAX_VALUE));
390398
// Other MAX_VALUEs
391399
assertEquals("63 KB", FileUtils.byteCountToDisplaySize(BigInteger.valueOf(Character.MAX_VALUE)));

src/test/java/org/apache/commons/io/channels/FileChannelsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ enum FileChannelType {
5959
private static final String CONTENT = StringUtils.repeat("x", SMALL_BUFFER_SIZE);
6060

6161
@SuppressWarnings("resource") // Caller closes
62-
private static FileChannel getChannel(final FileInputStream inNotEmpty, final FileChannelType fileChannelType, final int readSize) throws IOException {
62+
private static FileChannel getChannel(final FileInputStream inNotEmpty, final FileChannelType fileChannelType, final int readSize) {
6363
return wrap(inNotEmpty.getChannel(), fileChannelType, readSize);
6464
}
6565

@@ -84,7 +84,7 @@ private static byte reverse(final byte b) {
8484
return (byte) (~b & 0xff);
8585
}
8686

87-
private static FileChannel wrap(final FileChannel fc, final FileChannelType fileChannelType, final int readSize) throws IOException {
87+
private static FileChannel wrap(final FileChannel fc, final FileChannelType fileChannelType, final int readSize) {
8888
switch (fileChannelType) {
8989
case NON_BLOCKING:
9090
return new NonBlockingFileChannelProxy(fc);

src/test/java/org/apache/commons/io/comparator/CompositeFileComparatorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ void testConstructorIterable_order() {
116116
assertTrue(c.compare(moreFile, lessFile) > 0, "more");
117117
}
118118

119+
@Override
119120
@Test
120121
void testToString() {
121122
final List<Comparator<File>> list = new ArrayList<>();

src/test/java/org/apache/commons/io/file/CopyDirectoryVisitorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void testCopyDirectoryEmptyFolderFilters(final PathCounters pathCounters) throws
107107
void testCopyDirectoryFilters(final PathCounters pathCounters) throws IOException {
108108
final Path sourceDir = Paths.get("src/test/resources/org/apache/commons/io/dirs-2-file-size-4");
109109
final CopyDirectoryVisitor visitFileTree = PathUtils.visitFileTree(new CopyDirectoryVisitor(pathCounters, new NameFileFilter("file-size-1.bin"),
110-
new NameFileFilter("dirs-2-file-size-4", "dirs-a-file-size-1"), sourceDir, targetDir, null),
110+
new NameFileFilter("dirs-2-file-size-4", "dirs-a-file-size-1"), sourceDir, targetDir, (CopyOption[]) null),
111111
sourceDir);
112112
assertCounts(2, 1, 2, visitFileTree);
113113
assertArrayEquals(PathUtils.EMPTY_COPY_OPTIONS, visitFileTree.getCopyOptions());

src/test/java/org/apache/commons/io/function/IOIterableTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ void testIterator() throws IOException {
7777
}
7878

7979
@Test
80-
void testSpliterator() throws IOException {
80+
void testSpliterator() {
8181
final AtomicInteger ref = new AtomicInteger();
8282
iterable.spliterator().forEachRemaining(e -> ref.incrementAndGet());
8383
assertEquals(2, ref.get());
8484
}
8585

8686
@Test
87-
void testUnrwap() throws IOException {
87+
void testUnrwap() {
8888
assertSame(fixture.list, iterable.unwrap());
8989
assertSame(fixture.unwrap(), iterable.unwrap());
9090
}

src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ private int writeByte(final AbstractByteArrayOutputStream<?> baout, final java.i
504504
return count;
505505
}
506506

507-
private int writeByte(final AbstractByteArrayOutputStream<?> baout, final java.io.ByteArrayOutputStream ref, final int[] instructions) throws IOException {
507+
private int writeByte(final AbstractByteArrayOutputStream<?> baout, final java.io.ByteArrayOutputStream ref, final int[] instructions) {
508508
int written = 0;
509509
for (final int instruction : instructions) {
510510
written += writeByte(baout, ref, instruction);

0 commit comments

Comments
 (0)