Convert AttachmentCipherTest to kotlin.

This commit is contained in:
Greyson Parrelli
2025-06-11 11:58:35 -04:00
parent a46e1a451f
commit f8d8558cdb
4 changed files with 556 additions and 540 deletions

View File

@@ -127,8 +127,8 @@ fun InputStream.limit(limit: Long): LimitedInputStream {
*
* @param closeInputStream If true, the input stream will be closed after the copy is complete.
*/
fun InputStream.copyTo(outputStream: OutputStream, closeInputStream: Boolean = true): Long {
return StreamUtil.copy(this, outputStream, closeInputStream)
fun InputStream.copyTo(outputStream: OutputStream, closeInputStream: Boolean = true, closeOutputStream: Boolean = true): Long {
return StreamUtil.copy(this, outputStream, closeInputStream, closeOutputStream)
}
/**

View File

@@ -96,10 +96,10 @@ public final class StreamUtil {
}
public static long copy(InputStream in, OutputStream out) throws IOException {
return copy(in, out, true);
return copy(in, out, true, true);
}
public static long copy(InputStream in, OutputStream out, boolean closeInputStream) throws IOException {
public static long copy(InputStream in, OutputStream out, boolean closeInputStream, boolean closeOutputStream) throws IOException {
byte[] buffer = new byte[64 * 1024];
int read;
long total = 0;
@@ -114,7 +114,10 @@ public final class StreamUtil {
}
out.flush();
out.close();
if (closeOutputStream) {
out.close();
}
return total;
}