new class representing a storage
This commit is contained in:
46
src/java/com/wasteinformationserver/basicutils/Storage.kt
Normal file
46
src/java/com/wasteinformationserver/basicutils/Storage.kt
Normal 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()
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user