com.github.insanusmokrassar.AutoPostTelegramBot.utils.Files.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of AutoPostTelegramBot Show documentation
Show all versions of AutoPostTelegramBot Show documentation
It is base library for creating smart bot for simple management of channels posts
package com.github.insanusmokrassar.AutoPostTelegramBot.utils
import kotlinx.serialization.KSerializer
import kotlinx.serialization.json.Json
import java.io.FileInputStream
import java.io.InputStream
fun load(
filename: String,
serializer: KSerializer,
deserializationMethod: (InputStream) -> T = {
val data = it.reader().readText()
Json.parse(
serializer,
data
)
}
): T {
return (ClassLoader.getSystemResourceAsStream(filename) ?: FileInputStream(filename)).let(deserializationMethod)
}