/*
|
Helix - Dateiverwaltung
|
Copyright (C) 2021 Ulrich Hilger
|
|
This program is free software: you can redistribute it and/or modify
|
it under the terms of the GNU Affero General Public License as
|
published by the Free Software Foundation, either version 3 of the
|
License, or (at your option) any later version.
|
|
This program is distributed in the hope that it will be useful,
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
GNU Affero General Public License for more details.
|
|
You should have received a copy of the GNU Affero General Public License
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
*/
|
package de.uhilger.calypso.neu;
|
|
import java.io.File;
|
import java.io.FileInputStream;
|
import java.io.FileNotFoundException;
|
import java.io.IOException;
|
import java.io.InputStream;
|
import java.util.Properties;
|
import java.util.logging.Level;
|
import java.util.logging.Logger;
|
|
/**
|
*
|
* @author Ulrich Hilger
|
* @version 1, 01.06.2021
|
*/
|
public class AppProperties extends Properties {
|
|
public static final String EMPTY_STR = "";
|
public static final int INT_ZERO = 0;
|
|
public String getString(String key) {
|
Object o = this.get(key);
|
if(o instanceof String) {
|
return (String) o;
|
} else {
|
return EMPTY_STR;
|
}
|
}
|
|
public int getInt(String key) {
|
Object o = this.get(key);
|
if(o instanceof String) {
|
String intStr = (String) o;
|
return Integer.parseInt(intStr);
|
} else {
|
return INT_ZERO;
|
}
|
}
|
|
public void readFile(String fName) {
|
Logger.getLogger(AppProperties.class.getName()).log(Level.INFO, fName);
|
InputStream in = null;
|
try {
|
File einstellungenDatei = new File(fName);
|
in = new FileInputStream(einstellungenDatei);
|
load(in);
|
in.close();
|
} catch (FileNotFoundException ex) {
|
Logger.getLogger(AppProperties.class.getName()).log(Level.SEVERE, null, ex);
|
} catch (IOException ex) {
|
Logger.getLogger(AppProperties.class.getName()).log(Level.SEVERE, null, ex);
|
} finally {
|
try {
|
in.close();
|
} catch (IOException ex) {
|
Logger.getLogger(AppProperties.class.getName()).log(Level.SEVERE, null, ex);
|
}
|
}
|
}
|
}
|