相关疑难解决方法(0)

如何从Kotlin的资源中读取文本文件?

我想在Kotlin写一个Spek测试.测试应从该src/test/resources文件夹中读取HTML文件.怎么做?

class MySpec : Spek({

    describe("blah blah") {

        given("blah blah") {

            var fileContent : String = ""

            beforeEachTest {
                // How to read the file file.html in src/test/resources/html
                fileContent = ...  
            }

            it("should blah blah") {
                ...
            }
        }
    }
})
Run Code Online (Sandbox Code Playgroud)

kotlin

66
推荐指数
10
解决办法
4万
查看次数

标签 统计

kotlin ×1