new class representing a storage

This commit is contained in:
lukas-heiligenbrunner
2020-03-27 10:06:24 +01:00
parent ac3fce2913
commit cded7c7d27
3 changed files with 48 additions and 105 deletions

View File

@ -0,0 +1,46 @@
package com.wasteinformationserver.basicutils
import java.io.FileInputStream
import java.io.FileNotFoundException
import java.io.FileOutputStream
import java.io.IOException
import java.util.*
/**
* Storeage of user information
* * database infos
* * mqtt infos
*
* @author Lukas Heiligenbrunner
*/
class Storage {
companion object {
val obj = Storage()
fun getInstance(): Storage {
return obj;
}
}
var mqttServer: String = "";
/**
* init config file
*/
fun init() {
val prop = Properties()
try {
// try to load existing config file
val inp = FileInputStream("settings.prop")
prop.load(inp)
} catch (ee: FileNotFoundException) {
// file not generated yet
prop.store(FileOutputStream("settings.prop"), "")
Log.info("new Settings config file generated")
} catch (e: IOException) {
e.printStackTrace()
}
}
}