I am programming an application that resembles a library. The program will save the author, title, date and subject of a book in a text file, each field separated by commas, in this way:
Don Juan Manuel, Count Lucanor, 1331, novel
The user, of a specific book, can modify both the author, the title, the date and the subject. To do this you must first search for that book, entering its title. My question is this. How do I make my program search, according to the name entered, the file line where it is, and when it does, how to modify any of its fields? I have tried the following. No results:
Path miPath = FileSystems.getDefault().getPath("access.txt");
ArrayList<String> fileContent = new ArrayList<>(Files.readAllLines(miPath, StandardCharsets.UTF_8));
String[] miLista = new String[fileContent.size() * 4];
for (int i = 0; i < fileContent.size(); i++) {
miLista=fileContent.get(i).split(",");
}
//Solo guarda la ultima linea del fichero, mi intencion
//es guardar en un array todos los elementos separados por
//, para poder buscarlos recorriendo dicho array
Files.write(miPath, fileContent, StandardCharsets.UTF_8);