com.github.leandroborgesferreira.dagcommand.output.Files.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dag-command Show documentation
Show all versions of dag-command Show documentation
Affected gradle modules by branch
package com.github.leandroborgesferreira.dagcommand.output
import java.io.BufferedWriter
import java.io.File
fun writeToFile(directory: File, fileName: String, content: Iterable) {
createFileBuffer(directory, fileName).use { writer ->
content.forEach { line ->
writer.write(line)
writer.newLine()
}
}
}
fun writeToFile(directory: File, fileName: String, content: String) {
createFileBuffer(directory, fileName).use { writer ->
writer.write(content)
}
}
private fun createFileBuffer(directory: File, fileName: String): BufferedWriter {
if (!directory.exists()) directory.mkdirs()
return File(directory.path, fileName)
.outputStream()
.bufferedWriter()
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy