You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.4 KiB
38 lines
1.4 KiB
import device.Device;
|
|
|
|
import java.io.FileReader;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.util.Arrays;
|
|
import java.util.Properties;
|
|
|
|
public class BordComputer {
|
|
|
|
String[] deviceNames;
|
|
Device[] installedDevices;
|
|
Device activeDevice = null;
|
|
|
|
public void readConfig() throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
|
|
|
|
try (FileReader reader = new FileReader("Geraete.config")) {
|
|
Properties properties = new Properties();
|
|
properties.load(reader);
|
|
String[] values = properties.values().toArray(new String[0]);
|
|
Arrays.sort(values);
|
|
deviceNames = new String[values.length];
|
|
System.arraycopy(values, 0, deviceNames, 0, properties.size());
|
|
installedDevices = new Device[values.length];
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
setDevices();
|
|
activeDevice = installedDevices[0];
|
|
}
|
|
|
|
public void setDevices() throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, ClassNotFoundException {
|
|
Class<?> c;
|
|
for (int i = 0; i < deviceNames.length; i++) {
|
|
c = Class.forName(deviceNames[i]);
|
|
installedDevices[i] = (Device) c.getConstructor().newInstance();
|
|
}
|
|
}
|
|
}
|