0
delete student record from text file
How do i delete a student record from a text file via there student number. I tried using contains. But that only allows for a string amd the student number is an int.
7 Antworten
+ 4
if the student number is part of a text file it will be part of a string.
Load each row of the text file in an array of strings
Go through the array and if you find a substring that equals the number of the student, delete the corresponding row.
According to how the data is structured you may want to check only a defined part of each row to avoid that your program matches the sudent number within, let's say the phone number or the address of another student.
+ 3
These are examples for storing each line of a text file into strings
https://howtodoinjava.com/core-java/io/java-read-file-to-string-examples/
and find a substring within a string
http://www.geeksforgeeks.org/searching-for-character-and-substring-in-a-string/
+ 1
THANKS BRO!!!!
0
have you tried using Hashmaps?
0
No, I have no idea how to use that....
0
Would you be able to give me the code for that? I’m really stuck.
0
@seamiki