diff --git a/src/main/java/listfix/io/readers/IniFileReader.java b/src/main/java/listfix/io/readers/IniFileReader.java index 612d6e7e..863f276d 100644 --- a/src/main/java/listfix/io/readers/IniFileReader.java +++ b/src/main/java/listfix/io/readers/IniFileReader.java @@ -82,24 +82,26 @@ else if (in_data2.length() == 0) } } - public void readIni() throws IOException - { - List tempList = new ArrayList<>(); - List lines = Files.readAllLines(Paths.get(fname1), StandardCharsets.UTF_8); - - // Read in base media directories - // skip first line, contains header - int i = 1; - while (i < lines.size()) + private static int readIniEntries(int lineNr, List tempList, List lines) { + while (lineNr < lines.size()) { - String line = lines.get(i++); + String line = lines.get(lineNr++); if (line.startsWith("[")) { - ++i; break; } tempList.add(line); } + return lineNr; + } + + public void readIni() throws IOException + { + List tempList = new ArrayList<>(); + List lines = Files.readAllLines(Paths.get(fname1), StandardCharsets.UTF_8); + // Read in base media directories + // skip first line, contains header + int lineNr = readIniEntries(1, tempList, lines); mediaDirs = new String[tempList.size()]; tempList.toArray(mediaDirs); @@ -107,26 +109,15 @@ public void readIni() throws IOException // Read in media library directories // skip first line, contains header - while (i < lines.size()) - { - String line = lines.get(i++); - if (line.startsWith("[")) { - ++i; - break; - } - tempList.add(line); - } + lineNr = readIniEntries(lineNr, tempList, lines); mediaLibrary = new String[tempList.size()]; tempList.toArray(mediaLibrary); tempList.clear(); // Read in media library files // skip first line, contains header - while (i < lines.size()) - { - String line = lines.get(i++); - tempList.add(line); - } + readIniEntries(lineNr, tempList, lines); + mediaLibraryFiles = new String[tempList.size()]; tempList.toArray(mediaLibraryFiles); tempList.clear();