diff options
author | Sven Gothel <[email protected]> | 2023-05-04 00:48:15 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-05-04 00:48:15 +0200 |
commit | 69d22df0a6132dbf8b88fd04090c0bc81129237f (patch) | |
tree | 08e57ae187171b828b5b015042faa0e871afa271 /src | |
parent | 6545ab42048dfda5f6cb72ce272a331078cd200e (diff) |
IOUtil.copyStream2{File|Stream)(..): Drop unused and misleading 'totalNumBytes' argument, since we have no user-feedback callback passed.
Diffstat (limited to 'src')
4 files changed, 13 insertions, 17 deletions
diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java index 045525c..32e7505 100644 --- a/src/java/com/jogamp/common/util/IOUtil.java +++ b/src/java/com/jogamp/common/util/IOUtil.java @@ -171,7 +171,7 @@ public class IOUtil { */ /** - * Copy the specified URL resource to the specified output file. The total + * Copy the complete specified URL resource to the specified output file. The total * number of bytes written is returned. * * @param conn the open URLConnection @@ -185,7 +185,7 @@ public class IOUtil { int totalNumBytes = 0; final InputStream in = new BufferedInputStream(conn.getInputStream()); try { - totalNumBytes = copyStream2File(in, outFile, conn.getContentLength()); + totalNumBytes = copyStream2File(in, outFile); } finally { in.close(); } @@ -193,51 +193,47 @@ public class IOUtil { } /** - * Copy the specified input stream to the specified output file. The total + * Copy the complete specified input stream to the specified output file. The total * number of bytes written is returned. * * @param in the source * @param outFile the destination - * @param totalNumBytes informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown * @return * @throws IOException */ - public static int copyStream2File(final InputStream in, final File outFile, int totalNumBytes) throws IOException { + public static int copyStream2File(final InputStream in, final File outFile) throws IOException { final OutputStream out = new BufferedOutputStream(new FileOutputStream(outFile)); try { - totalNumBytes = copyStream2Stream(in, out, totalNumBytes); + return copyStream2Stream(in, out); } finally { out.close(); } - return totalNumBytes; } /** - * Copy the specified input stream to the specified output stream. The total + * Copy the complete specified input stream to the specified output stream. The total * number of bytes written is returned. * * @param in the source * @param out the destination - * @param totalNumBytes informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown * @return * @throws IOException */ - public static int copyStream2Stream(final InputStream in, final OutputStream out, final int totalNumBytes) throws IOException { - return copyStream2Stream(Platform.getMachineDataInfo().pageSizeInBytes(), in, out, totalNumBytes); + public static int copyStream2Stream(final InputStream in, final OutputStream out) throws IOException { + return copyStream2Stream(Platform.getMachineDataInfo().pageSizeInBytes(), in, out); } /** - * Copy the specified input stream to the specified output stream. The total + * Copy the complete specified input stream to the specified output stream. The total * number of bytes written is returned. * * @param bufferSize the intermediate buffer size, should be {@link MachineDataInfo#pageSizeInBytes()} for best performance. * @param in the source * @param out the destination - * @param totalNumBytes informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown * @return * @throws IOException */ - public static int copyStream2Stream(final int bufferSize, final InputStream in, final OutputStream out, final int totalNumBytes) throws IOException { + public static int copyStream2Stream(final int bufferSize, final InputStream in, final OutputStream out) throws IOException { final byte[] buf = new byte[bufferSize]; int numBytes = 0; while (true) { diff --git a/src/java/com/jogamp/common/util/JarUtil.java b/src/java/com/jogamp/common/util/JarUtil.java index aa5719c..d621e1c 100644 --- a/src/java/com/jogamp/common/util/JarUtil.java +++ b/src/java/com/jogamp/common/util/JarUtil.java @@ -628,7 +628,7 @@ public class JarUtil { final OutputStream out = new BufferedOutputStream(new FileOutputStream(destFile)); int numBytes = -1; try { - numBytes = IOUtil.copyStream2Stream(BUFFER_SIZE, in, out, -1); + numBytes = IOUtil.copyStream2Stream(BUFFER_SIZE, in, out); } finally { in.close(); out.close(); diff --git a/src/junit/com/jogamp/common/nio/TestByteBufferInputStream.java b/src/junit/com/jogamp/common/nio/TestByteBufferInputStream.java index 90a954b..bbe815d 100644 --- a/src/junit/com/jogamp/common/nio/TestByteBufferInputStream.java +++ b/src/junit/com/jogamp/common/nio/TestByteBufferInputStream.java @@ -265,7 +265,7 @@ public class TestByteBufferInputStream extends SingletonJunitCase { final long t1 = System.currentTimeMillis(); final File out = new File(fileOut); - IOUtil.copyStream2File(bis, out, -1); + IOUtil.copyStream2File(bis, out); final long t2 = System.currentTimeMillis(); final String suffix; diff --git a/src/junit/com/jogamp/junit/util/MiscUtils.java b/src/junit/com/jogamp/junit/util/MiscUtils.java index 3576fed..03d4d13 100644 --- a/src/junit/com/jogamp/junit/util/MiscUtils.java +++ b/src/junit/com/jogamp/junit/util/MiscUtils.java @@ -103,7 +103,7 @@ public class MiscUtils { } final InputStream in = new BufferedInputStream(new FileInputStream(src)); try { - stats.totalBytes += IOUtil.copyStream2File(in, dest, 0); + stats.totalBytes += IOUtil.copyStream2File(in, dest); } finally { in.close(); } |