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

ai.digital.integration.server.common.util.PropertiesUtil.kt Maven / Gradle / Ivy

There is a newer version: 23.3.0-1025.941
Show newest version
package ai.digital.integration.server.common.util

import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.util.*

class PropertiesUtil {
    companion object {

        fun readPropertiesFile(file: File): Properties {
            val properties = Properties()
            if (!file.exists()) {
                file.createNewFile()
            }
            val fis = FileInputStream(file.absolutePath)
            properties.load(fis)
            return properties
        }

        fun readProperty(file: File, key: String): String {
            return readPropertiesFile(file).get(key).toString()
        }

        fun writePropertiesFile(file: File, properties: Properties) {
            val fos = FileOutputStream(file.absolutePath)
            properties.store(fos, null)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy