I am trying to read text from three separate files. I couldn't think of a cleaner way to use only one BufferedReader. And is there a way to save text in to a empty part of an array without creating byte i = 0
.
I am new to Java, So thanks for answering in advance.
String unitsPath = "SI_system_units.txt";
String namesPath = "SI_system_units_names.txt";
String definitionsPath = "SI_system_definitions.txt";
String line;
byte i = 0;
String[] siUnits = new String[100];
String[] siNames = new String[100];
String[] siDefinitions = new String[100];
BufferedReader unitsBr = new BufferedReader(new FileReader(unitsPath));
BufferedReader namesBr = new BufferedReader(new FileReader(namesPath));
BufferedReader definitionsBr = new BufferedReader(new FileReader(definitionsPath));
while ((line = unitsBr.readLine()) != null) {
siUnits[i] = line.trim();
siNames[i] = namesBr.readLine().trim();
siDefinitions[i] = definitionsBr.readLine().trim();
i++;
}