val path = Paths.get("src/TestJava.java");
var stream = Files.newInputStream(path)
stream.buffered(1024).reader(Charsets.UTF_8).use {
reader-> println("current:${reader.readText()}");//一次读完
}
只读入一行
stream.buffered(1024).reader(Charsets.UTF_8).useLines { reader ->
var iterator = reader.iterator()
while (iterator.hasNext()) {
println("current:${iterator.next()}");
}
}
···