Skip to content

Nishant-2608/java-file-operations-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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 ▢️ Run button or press Shift + F10.

Interact via the Console

A menu will appear where you can select different file operations.

πŸ§ͺ 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.

βœ… File created and written successfully!

πŸ’‘ 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages