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-compress.git
The following commit(s) were added to refs/heads/master by this push: new 08490c864 Use NIO 08490c864 is described below commit 08490c864063ec8b80ed00b9b9d6e0b3246c0f81 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Tue Dec 10 09:43:27 2024 -0500 Use NIO --- .../org/apache/commons/compress/archivers/CpioTest.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/apache/commons/compress/archivers/CpioTest.java b/src/test/java/org/apache/commons/compress/archivers/CpioTest.java index d9914fbc7..c1ebd7efa 100644 --- a/src/test/java/org/apache/commons/compress/archivers/CpioTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/CpioTest.java @@ -159,12 +159,7 @@ public final class CpioTest extends AbstractTest { in.setSize(tmp.length()); in.setMode(CpioConstants.C_ISREG); tos.putArchiveEntry(in); - final byte[] b = new byte[(int) tmp.length()]; - try (InputStream fis = Files.newInputStream(tmp.toPath())) { - while (fis.read(b) > 0) { - tos.write(b); - } - } + Files.copy(tmp.toPath(), tos); tos.closeArchiveEntry(); } final CpioArchiveEntry out; @@ -185,12 +180,7 @@ public final class CpioTest extends AbstractTest { try (CpioArchiveOutputStream tos = new CpioArchiveOutputStream(Files.newOutputStream(archive.toPath()))) { final CpioArchiveEntry in = new CpioArchiveEntry(tmp, "foo"); tos.putArchiveEntry(in); - final byte[] b = new byte[(int) tmp.length()]; - try (InputStream fis = Files.newInputStream(tmp.toPath())) { - while (fis.read(b) > 0) { - tos.write(b); - } - } + Files.copy(tmp.toPath(), tos); tos.closeArchiveEntry(); } final CpioArchiveEntry out; @@ -203,4 +193,5 @@ public final class CpioTest extends AbstractTest { assertEquals(tmp.lastModified() / 1000, out.getLastModifiedDate().getTime() / 1000); assertFalse(out.isDirectory()); } + }