Move ByteArray.inputStream() method from kotlin package to kotlin.io
This commit is contained in:
@@ -59,13 +59,15 @@ import kotlin.jvm.internal.Intrinsic
|
|||||||
/**
|
/**
|
||||||
* Creates an input stream for reading data from this byte array.
|
* Creates an input stream for reading data from this byte array.
|
||||||
*/
|
*/
|
||||||
@Deprecated("Use inputStream() method instead.", ReplaceWith("this.inputStream()"))
|
@Deprecated("Use inputStream() method instead.", ReplaceWith("this.inputStream()", "kotlin.io.inputStream"))
|
||||||
public val ByteArray.inputStream : ByteArrayInputStream
|
public val ByteArray.inputStream : ByteArrayInputStream
|
||||||
get() = inputStream()
|
get() = inputStream()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an input stream for reading data from this byte array.
|
* Creates an input stream for reading data from this byte array.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Use inputStream() method from kotlin.io package instead.", ReplaceWith("this.inputStream()", "kotlin.io.inputStream"))
|
||||||
|
@HiddenDeclaration
|
||||||
public fun ByteArray.inputStream(): ByteArrayInputStream = ByteArrayInputStream(this)
|
public fun ByteArray.inputStream(): ByteArrayInputStream = ByteArrayInputStream(this)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,6 +75,8 @@ public fun ByteArray.inputStream(): ByteArrayInputStream = ByteArrayInputStream(
|
|||||||
* @param offset the start offset of the portion of the array to read.
|
* @param offset the start offset of the portion of the array to read.
|
||||||
* @param length the length of the portion of the array to read.
|
* @param length the length of the portion of the array to read.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Use inputStream() method from kotlin.io package instead.", ReplaceWith("this.inputStream(offset, length)", "kotlin.io.inputStream"))
|
||||||
|
@HiddenDeclaration
|
||||||
public fun ByteArray.inputStream(offset: Int, length: Int) : ByteArrayInputStream = ByteArrayInputStream(this, offset, length)
|
public fun ByteArray.inputStream(offset: Int, length: Int) : ByteArrayInputStream = ByteArrayInputStream(this, offset, length)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -46,6 +46,18 @@ public fun InputStream.iterator(): ByteIterator =
|
|||||||
/** Creates a new byte input stream for the string. */
|
/** Creates a new byte input stream for the string. */
|
||||||
public fun String.byteInputStream(charset: Charset = Charsets.UTF_8): InputStream = ByteArrayInputStream(toByteArray(charset))
|
public fun String.byteInputStream(charset: Charset = Charsets.UTF_8): InputStream = ByteArrayInputStream(toByteArray(charset))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an input stream for reading data from this byte array.
|
||||||
|
*/
|
||||||
|
public fun ByteArray.inputStream(): ByteArrayInputStream = ByteArrayInputStream(this)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an input stream for reading data from the specified portion of this byte array.
|
||||||
|
* @param offset the start offset of the portion of the array to read.
|
||||||
|
* @param length the length of the portion of the array to read.
|
||||||
|
*/
|
||||||
|
public fun ByteArray.inputStream(offset: Int, length: Int) : ByteArrayInputStream = ByteArrayInputStream(this, offset, length)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a buffered input stream wrapping this stream.
|
* Creates a buffered input stream wrapping this stream.
|
||||||
* @param bufferSize the buffer size to use.
|
* @param bufferSize the buffer size to use.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import org.junit.Test as test
|
|||||||
|
|
||||||
class OldStdlibTest() {
|
class OldStdlibTest() {
|
||||||
@test fun testCollectionEmpty() {
|
@test fun testCollectionEmpty() {
|
||||||
assertNot {
|
assertFalse {
|
||||||
listOf(0, 1, 2).isEmpty()
|
listOf(0, 1, 2).isEmpty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,8 +27,10 @@ class OldStdlibTest() {
|
|||||||
x [index] = index.toByte()
|
x [index] = index.toByte()
|
||||||
}
|
}
|
||||||
|
|
||||||
for(b in x.inputStream()) {
|
x.inputStream().use { stream ->
|
||||||
println(b)
|
for(b in stream) {
|
||||||
|
println(b)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user