Avoid introducing Path.printWriter

#KT-19192
This commit is contained in:
Ilya Gorbunov
2020-10-19 06:52:13 +03:00
parent 9f659d74df
commit e7c888a2e6
2 changed files with 0 additions and 39 deletions
@@ -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)