Avoid introducing Path.printWriter
#KT-19192
This commit is contained in:
@@ -72,16 +72,6 @@ public inline fun Path.bufferedWriter(
|
||||
return writer(charset, *options).buffered(bufferSize)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new [PrintWriter] for writing the content of this file.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@ExperimentalPathApi
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun Path.printWriter(charset: Charset = Charsets.UTF_8, vararg options: OpenOption): PrintWriter {
|
||||
return PrintWriter(bufferedWriter(charset, options = options))
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entire content of this file as a byte array.
|
||||
*
|
||||
|
||||
@@ -91,35 +91,6 @@ class PathReadWriteTest {
|
||||
assertEquals(Files.readAllLines(file, Charsets.UTF_8), listOf("line1", "line2"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPrintWriter() {
|
||||
val file = Files.createTempFile(null, null)
|
||||
|
||||
val writer = file.printWriter()
|
||||
val str1 = "Hello, world!"
|
||||
val str2 = "Everything is wonderful!"
|
||||
writer.println(str1)
|
||||
writer.println(str2)
|
||||
writer.close()
|
||||
|
||||
val writer2 = file.printWriter(options = arrayOf(StandardOpenOption.APPEND))
|
||||
val str3 = "Hello again!"
|
||||
writer2.println(str3)
|
||||
writer2.close()
|
||||
|
||||
val writer3 = file.printWriter(Charsets.UTF_8, StandardOpenOption.APPEND)
|
||||
val str4 = "Hello one last time!"
|
||||
writer3.println(str4)
|
||||
writer3.close()
|
||||
|
||||
file.bufferedReader().use { reader ->
|
||||
assertEquals(str1, reader.readLine())
|
||||
assertEquals(str2, reader.readLine())
|
||||
assertEquals(str3, reader.readLine())
|
||||
assertEquals(str4, reader.readLine())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWriteBytes() {
|
||||
val file = Files.createTempFile(null, null)
|
||||
|
||||
Reference in New Issue
Block a user