From b46bb17377e5eb713472f35da9a310adb0291fb5 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Thu, 22 Mar 2012 07:20:26 +0000 Subject: [PATCH] corrected type of OutputStream.buffered() and fail if UTF-8 default charset can't be found - thanks for the heads up Stepan! :) --- libraries/stdlib/src/JavaIo.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/stdlib/src/JavaIo.kt b/libraries/stdlib/src/JavaIo.kt index 8b8692fbc41..523e5ae29b4 100644 --- a/libraries/stdlib/src/JavaIo.kt +++ b/libraries/stdlib/src/JavaIo.kt @@ -13,7 +13,7 @@ public val defaultBufferSize: Int = 64 * 1024 /** * Returns the default [[Charset]] which defaults to UTF-8 */ -public val defaultCharset: Charset = Charset.forName("UTF-8") ?: Charset.defaultCharset().sure() +public val defaultCharset: Charset = Charset.forName("UTF-8").sure() /** Prints the given message to [[System.out]] */ @@ -192,8 +192,8 @@ inline fun InputStream.reader(encoding: String) = InputStreamReader(this, encodi inline fun InputStream.reader(encoding: CharsetDecoder) = InputStreamReader(this, encoding) -inline fun OutputStream.buffered(bufferSize: Int = defaultBufferSize) : BufferedWriter - = if (this is BufferedWriter) this else BufferedWriter(writer(), bufferSize) +inline fun OutputStream.buffered(bufferSize: Int = defaultBufferSize) : BufferedOutputStream + = if (this is BufferedOutputStream) this else BufferedOutputStream(this, bufferSize) inline fun OutputStream.writer(encoding: Charset = defaultCharset) : OutputStreamWriter = OutputStreamWriter(this, encoding)