Skip to content
This repository was archived by the owner on Sep 15, 2020. It is now read-only.

Commit 93ae681

Browse files
committed
Fix #7
1 parent 717953b commit 93ae681

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/main/resources/template/gradle-kotlin-dsl/build.gradle.kts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import java.io.IOException
2+
import java.io.InputStream
3+
import java.io.OutputStream
4+
import java.util.*
5+
16
plugins {
27
kotlin("jvm") version "1.3.71"
38
java
@@ -65,7 +70,7 @@ tasks {
6570
?.let {
6671
println("Coping ${it.name}")
6772
it.inputStream()
68-
.transferTo(File("$testConsoleDir/plugins/${it.name}").apply { createNewFile() }
73+
.transferTo1(File("$testConsoleDir/plugins/${it.name}").apply { createNewFile() }
6974
.outputStream())
7075
println("Copied ${it.name}")
7176
}
@@ -83,4 +88,18 @@ tasks {
8388
args(miraiCoreVersion, miraiConsoleVersion)
8489
}
8590
}
91+
}
92+
93+
94+
@Throws(IOException::class)
95+
fun InputStream.transferTo1(out: OutputStream): Long {
96+
Objects.requireNonNull(out, "out")
97+
var transferred: Long = 0
98+
val buffer = ByteArray(8192)
99+
var read: Int
100+
while (this.read(buffer, 0, InputStream.DEFAULT_BUFFER_SIZE).also { read = it } >= 0) {
101+
out.write(buffer, 0, read)
102+
transferred += read.toLong()
103+
}
104+
return transferred
86105
}

0 commit comments

Comments
 (0)