Commit 45681d0f authored by Pony's avatar Pony

loading from file added

parent 0bdd2e9a
......@@ -23,6 +23,7 @@ package lu.list.itis.dkd.tui.utility;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -93,10 +94,23 @@ public final class PropertiesFetcher {
public static Properties fetchProperties(final String location) {
Properties userDefinedProperties = new Properties();
try {
userDefinedProperties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(location));
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
InputStream is = contextClassLoader.getResourceAsStream(location);
userDefinedProperties.load(is);
} catch (final IOException e) {
Logger.getLogger(PropertiesFetcher.class.getSimpleName()).log(Level.SEVERE, "The porperties file could not be loaded!", e); //$NON-NLS-1$
} catch (final NullPointerException e) {
try (FileInputStream inputStream = new FileInputStream(new File(location))) {
properties = new Properties();
properties.load(inputStream);
return properties;
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
return userDefinedProperties;
}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment