首页 > 解决方案 > Kotlin jvm html DOCTYPE

问题描述

我是一名 Java Dynosaur,前一天开始使用 Kotlin。

我发现自己在编码...

    fun toFile(relativePathAndFileName : String) { // file stream out
        File(relativePathAndFileName).printWriter().use { out ->
            out.appendLine("<!DOCTYPE html>")   // My question: is there a way to do this elegantly
                .appendHTML().html {
                    lang = "en"

输出没问题,因为它添加了<!DOCTYPE>,但代码out.appendLine("<!DOCTYPE html>")对我来说就像是 hack。如何以 Kotlin 的方式让它更漂亮?

标签: kotlin

解决方案


推荐阅读