This project demonstrates basic file handling operations in Java using the NIO (New I/O) package. It allows a user to create, read, write, append, modify, and delete text files dynamically through a console-based interactive menu.
Developed using IntelliJ IDEA, this program is ideal for learning file I/O operations, text manipulation, and exception handling in Java.
π§© Features Function Description π Write File Create a new text file and write user-provided lines. β Append Line Add a new line of text to an existing file. π Read File Display file content line by line with numbering. π Search & Replace Find and replace a word or phrase within the file. π Replace Specific Line Find a line containing specific text and replace it. ποΈ Delete File Delete the selected file. β Exit Safely close the program. π§ Technical Concepts Used
Java NIO (java.nio.file) package for efficient file handling (Files, Paths, StandardOpenOption, Path, etc.)
Exception Handling for safe file operations (try-with-resources, IOException handling)
Scanner class for dynamic user input
List for text line manipulation
Menu-driven console interface
UTF-8 character encoding for compatibility
βοΈ Requirements Tool Version Java JDK 17 or later IDE IntelliJ IDEA (Community or Ultimate Edition) Operating System Windows / macOS / Linux π§ How to Run the Project (Step-by-Step)
Open IntelliJ IDEA
Create a new Java project named FileOperationsDemo.
Add the source file
Create a new Java Class β Name it FileOperationsDemo.
Copy and paste the full program code (with comments) provided.
Run the Program
Click the green
Interact via the Console
π§ͺ Example Run === JAVA FILE OPERATIONS DEMO === Working Directory: C:\Users\User\IdeaProjects\FileOperationsDemo\demo_files
Choose an operation: 1 - Write new file 2 - Append line 3 - Read file 4 - Search & Replace text 5 - Replace specific line 6 - Delete file 7 - Exit Enter your choice: 1
Enter text lines (press ENTER on empty line to finish): Hello, this is a demo file. This program shows Java file operations.
π‘ Author
Name: Nishant Tiwari Role: Intern / Java Developer Organization: CodTEch Solutions IDE Used: IntelliJ IDEA Language: Java (JDK 17)
β A menu-driven Java application demonstrating:
Reading and writing text files
Modifying content
Handling user input dynamically
Clear inline documentation and README file