This is a simple Java program that demonstrates file handling operations such as writing to a file, reading from a file, searching for a name in a file, editing a name in a file, and deleting a name from a file.
- Write name in file: Allows the user to enter a name and writes it to a file.
- Read names from file: Reads all the names from the file and prints them.
- Search name from file: Searches for a name in the file and prints it if found.
- Edit name: Allows the user to edit a name in the file.
- Delete name: Allows the user to delete a name from the file.
- Quit: Exits the program.
- Compile: Compile the program using
javac FileHandling.java. - Run: Run the program using
java FileHandling. - Menu: Choose an option from the menu to perform the desired operation.
1. | Write name in file
2. | Read names from file
3. | Search name from file
4. | Edit name
5. | Delete name
6. | Quit
Enter your choice: 1
Enter the name: John Doe
Name written successfully!
- The program uses a text file named
names.txtto store the names. Make sure this file exists in the same directory as the program. - The program uses a simple text-based menu for user interaction.
This program was written by Ahsan Javed for educational purposes.
- This program was inspired by Prof. Rana Waqas (My SMD's course instructor) and is based on the concepts of file handling in Java.