All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.insanusmokrassar.AutoPostTelegramBot.utils.Files.kt Maven / Gradle / Ivy

Go to download

It is base library for creating smart bot for simple management of channels posts

There is a newer version: 1.7.0
Show newest version
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)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy