Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions konf-core/src/main/kotlin/com/uchuhimo/konf/source/Writer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ interface Writer {
* Save to specified file.
*
* @param file specified file
* @param mkdirs create all parent folders before writing
* @return a new source from specified file
*/
fun toFile(file: File) {
fun toFile(file: File, mkdirs: Boolean = false) {
if (mkdirs) file.parentFile.mkdirs()
file.outputStream().use {
toOutputStream(it)
}
Expand All @@ -54,8 +56,9 @@ interface Writer {
* Save to specified file path.
*
* @param file specified file path
* @param mkdirs create all parent folders before writing
*/
fun toFile(file: String) = toFile(File(file))
fun toFile(file: String, mkdirs: Boolean = false) = toFile(File(file), mkdirs)

/**
* Save to string.
Expand Down