MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / JSONLines

Class JSONLines

src/main/java/trace/util/JSONLines.kt:6–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4import org.json.JSONString
5import org.json.JSONStringer
6import java.io.File
7import java.lang.IllegalArgumentException
8import java.nio.file.Files
9
10class JSONLines(val fn: String) {
11 val lines = mutableListOf<String>()
12
13 var parseNow: java.util.function.BiFunction<JSONLines, Int, Any>? = null
14
15 init {
16 if (!File(fn).exists())
17 throw IllegalArgumentException(" file '$fn' doesn't exist?")
18
19 val lines = Files.readAllLines(File(fn).toPath())
20
21 for (ll in lines) {
22 val t = ll.trim()
23 if (t.length > 0) {
24 this.lines.add(t)
25 }
26 }
27 }
28
29 fun parse(n: Int): Any {
30 return parseNow!!.apply(this, n)
31 }

Callers

nothing calls this directly

Calls 3

FileFunction · 0.85
existsMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected