0
I am making a vehicle rental company in java need to read from a txt the type of client(char) a date range(string) and the amount of passengers(int).
I need to bring this data to be analyzed , for example according to the passenger Qtd I do calculations of which car is most suitable and according to the type of customer I do the calculation of fees, according to the day of the week has different values.
But I don’t know and I didn’t find any plausible explanation of how I do this linkage of the file variables to the correct variables in the code anyone can help me?
I’ll have you read the file:
private static void ler() {
File dir = new File("C:\\Arquivos");
File arq = new File(dir, "LocadoraCarro.txt");
try {
FileReader fileReader = new FileReader(arq);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String linha = "";
while ( ( linha = bufferedReader.readLine() ) != null) {
System.out.println(linha);
}
fileReader.close();
bufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
File Format : TIPO_DO_CLIENTE: QUANTIDADE_PASSAGEIROS: DATA1, DATA2, DATA3
Example: Normal: 2: 12Abr2018 (mon), 13Abr2018(Tue)
There are two different doubts there, I suggest you separate and leave only one, which is the txt reading.
– user28595
And you speak of a txt file but it does not show any lines demonstrative of this file. Edit the question and add a few lines of this file to facilitate understanding.
– user28595
@Article made the requested changes.
– ADR