Rename defaultBufferSize to DEFAULT_BUFFER_SIZE.
This commit is contained in:
@@ -6,7 +6,10 @@ package kotlin.io
|
||||
/**
|
||||
* Returns the default buffer size when working with buffered streams.
|
||||
*/
|
||||
public val defaultBufferSize: Int = 64 * 1024
|
||||
public val DEFAULT_BUFFER_SIZE: Int = 64 * 1024
|
||||
|
||||
@Deprecated("Use DEFAULT_BUFFER_SIZE constant instead.", ReplaceWith("kotlin.io.DEFAULT_BUFFER_SIZE"))
|
||||
public val defaultBufferSize: Int = DEFAULT_BUFFER_SIZE
|
||||
|
||||
/**
|
||||
* Returns the default block size for forEachBlock().
|
||||
|
||||
@@ -62,7 +62,7 @@ public fun ByteArray.inputStream(offset: Int, length: Int) : ByteArrayInputStrea
|
||||
* Creates a buffered input stream wrapping this stream.
|
||||
* @param bufferSize the buffer size to use.
|
||||
*/
|
||||
public fun InputStream.buffered(bufferSize: Int = defaultBufferSize): BufferedInputStream
|
||||
public fun InputStream.buffered(bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferedInputStream
|
||||
= if (this is BufferedInputStream) this else BufferedInputStream(this, bufferSize)
|
||||
|
||||
/** Creates a reader on this input stream using UTF-8 or the specified [charset]. */
|
||||
@@ -83,7 +83,7 @@ public fun InputStream.bufferedReader(charset: String): BufferedReader = reader(
|
||||
* Creates a buffered output stream wrapping this stream.
|
||||
* @param bufferSize the buffer size to use.
|
||||
*/
|
||||
public fun OutputStream.buffered(bufferSize: Int = defaultBufferSize): BufferedOutputStream
|
||||
public fun OutputStream.buffered(bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferedOutputStream
|
||||
= if (this is BufferedOutputStream) this else BufferedOutputStream(this, bufferSize)
|
||||
|
||||
/** Creates a writer on this output stream using UTF-8 or the specified [charset]. */
|
||||
@@ -105,7 +105,7 @@ public fun OutputStream.bufferedWriter(charset: String): BufferedWriter = writer
|
||||
*
|
||||
* **Note** It is the caller's responsibility to close both of these resources.
|
||||
*/
|
||||
public fun InputStream.copyTo(out: OutputStream, bufferSize: Int = defaultBufferSize): Long {
|
||||
public fun InputStream.copyTo(out: OutputStream, bufferSize: Int = DEFAULT_BUFFER_SIZE): Long {
|
||||
var bytesCopied: Long = 0
|
||||
val buffer = ByteArray(bufferSize)
|
||||
var bytes = read(buffer)
|
||||
@@ -122,7 +122,7 @@ public fun InputStream.copyTo(out: OutputStream, bufferSize: Int = defaultBuffer
|
||||
*
|
||||
* **Note**: It is the caller's responsibility to close this stream.
|
||||
*/
|
||||
public fun InputStream.readBytes(estimatedSize: Int = defaultBufferSize): ByteArray {
|
||||
public fun InputStream.readBytes(estimatedSize: Int = DEFAULT_BUFFER_SIZE): ByteArray {
|
||||
val buffer = ByteArrayOutputStream(estimatedSize)
|
||||
copyTo(buffer)
|
||||
return buffer.toByteArray()
|
||||
|
||||
@@ -9,11 +9,11 @@ import java.util.NoSuchElementException
|
||||
|
||||
|
||||
/** Returns a buffered reader wrapping this Reader, or this Reader itself if it is already buffered. */
|
||||
public fun Reader.buffered(bufferSize: Int = defaultBufferSize): BufferedReader
|
||||
public fun Reader.buffered(bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferedReader
|
||||
= if (this is BufferedReader) this else BufferedReader(this, bufferSize)
|
||||
|
||||
/** Returns a buffered reader wrapping this Writer, or this Writer itself if it is already buffered. */
|
||||
public fun Writer.buffered(bufferSize: Int = defaultBufferSize): BufferedWriter
|
||||
public fun Writer.buffered(bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferedWriter
|
||||
= if (this is BufferedWriter) this else BufferedWriter(this, bufferSize)
|
||||
|
||||
/**
|
||||
@@ -107,7 +107,7 @@ public fun Reader.readText(): String {
|
||||
* @param bufferSize size of character buffer to use in process.
|
||||
* @return number of bytes copies.
|
||||
*/
|
||||
public fun Reader.copyTo(out: Writer, bufferSize: Int = defaultBufferSize): Long {
|
||||
public fun Reader.copyTo(out: Writer, bufferSize: Int = DEFAULT_BUFFER_SIZE): Long {
|
||||
var charsCopied: Long = 0
|
||||
val buffer = CharArray(bufferSize)
|
||||
var chars = read(buffer)
|
||||
|
||||
@@ -262,7 +262,7 @@ public fun File.relativePath(descendant: File): String {
|
||||
* @throws FileAlreadyExistsException if the destination file already exists and 'rewrite' argument is set to `false`.
|
||||
* @throws IOException if any errors occur while copying.
|
||||
*/
|
||||
public fun File.copyTo(dst: File, overwrite: Boolean = false, bufferSize: Int = defaultBufferSize): Long {
|
||||
public fun File.copyTo(dst: File, overwrite: Boolean = false, bufferSize: Int = DEFAULT_BUFFER_SIZE): Long {
|
||||
if (!exists()) {
|
||||
throw NoSuchFileException(file = this, reason = "The source file doesn't exist")
|
||||
} else if (isDirectory()) {
|
||||
|
||||
Reference in New Issue
Block a user