- RandomAccessFile rafPropDef = new RandomAccessFile("defProps/" + strName, "r");
- prpStore = new Prop(getID(), strName);
- String strStore = rafPropDef.readLine();
- while (!(strStore == null || strStore.equals("."))) {
- if (strStore.equalsIgnoreCase("description")) {
- prpStore.description = rafPropDef.readLine();
- } else if (strStore.equalsIgnoreCase("image")) {
- prpStore.intImage = Integer.parseInt(rafPropDef.readLine());
- }
- strStore = rafPropDef.readLine();
- }
- rafPropDef.close();
+ String key = strName.toLowerCase();
+ Optional<Path> path = Files.find(Path.of("defProps"), 1, (t, a) -> t.getFileName().toString().toLowerCase().equals(key)).findAny();
+ if (path.isPresent()) {
+ RandomAccessFile rafPropDef = new RandomAccessFile(path.get().toFile(), "r");
+ prpStore = new Prop(getID(), strName);
+ String strStore = rafPropDef.readLine();
+ while (!(strStore == null || strStore.equals("."))) {
+ if (strStore.equalsIgnoreCase("description")) {
+ prpStore.description = rafPropDef.readLine();
+ } else if (strStore.equalsIgnoreCase("image")) {
+ prpStore.intImage = Integer.parseInt(rafPropDef.readLine());
+ }
+ strStore = rafPropDef.readLine();
+ }
+ rafPropDef.close();
+ } else {
+ throw new FileNotFoundException("defProps/" + key);
+ }