mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Convert AttachmentCipherTest to kotlin.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user