}
public static Configuration from(String propertiesFile) {
- InputStream input = null;
- try {
- input = new FileInputStream(propertiesFile);
- Properties prop = new Properties();
+ Properties prop = new Properties();
+ try (InputStream input = new FileInputStream(propertiesFile)) {
prop.load(input);
- return new Configuration(prop);
} catch (IOException ex) {
ex.printStackTrace();
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
}
- return null;
+ return new Configuration(prop);
}
private String get(Properties prop, String name) {
public class LedConfiguration {
public int cols;
public int rows;
- public int level;
+ public int brightness;
public LedType type;
private LedConfiguration(Properties prop) {
cols = Integer.parseInt(get(prop, "leds.cols"));
rows = Integer.parseInt(get(prop, "leds.rows"));
- level = Math.max(1, Math.min(31, Integer.parseInt(get(prop, "leds.level", "31"))));
+ brightness = Math.max(1, Math.min(31, Integer.parseInt(get(prop, "leds.brightness", "31"))));
switch (get(prop, "leds.type", "").toUpperCase()) {
case "WS2801":
type = LedType.WS2801;