A Java-based console application for text file manipulation using custom-built Data Structures.
Built entirely from scratch โ no Java Collections Framework used.
๐ฅ๏ธ GUI Version available โ
gui-versionbranch โ Built with JavaFX, Dark/Light theme, run on Replit!
Text File Manipulator is a Data Structures & Algorithms (DSA) project developed in Java. It provides a menu-driven console interface to perform a wide range of operations on .txt files โ all powered by custom implementations of Stack and Singly LinkedList, written entirely from scratch without using Java's built-in Collections Framework.
This project demonstrates how fundamental data structures can be applied to solve real-world file manipulation problems. ๐๏ธ
| Branch | Description | Run On |
|---|---|---|
๐ฅ๏ธ main |
Console-based version using Scanner & File I/O | ๐ค Terminal / CMD |
๐จ gui-version |
JavaFX GUI with Dark/Light theme toggle | ๐ Replit / Local |
| # | Operation | Description | Data Structure Used |
|---|---|---|---|
| 1 | ๐ซ Eliminate Repeated Lines | Removes all duplicate lines from the file | LinkedList (contains()) |
| 2 | ๐ Reverse File Content | Reverses the order of all lines in the file | Stack (LIFO) |
| 3 | โ Insert New Line | Inserts a new line after a target keyword | Stack |
| 4 | ๐ Copy Line | Copies a specific line to a clipboard | Stack (Clipboard) |
| 5 | ๐ Paste Line | Pastes clipboard content at a specified position | Stack + LinkedList |
| 6 | โ๏ธ Cut Line | Removes a line and stores it in clipboard | Stack (Clipboard) + LinkedList |
| 7 | ๐ค Sort File Content | Sorts lines alphabetically using Bubble Sort | Array + Bubble Sort |
| 8 | ๐ Merge Files | Appends content of one file into another | LinkedList |
| 9 | ๐ช Exit | Exits the program gracefully | โ |
Text-File-Manipulator/
โ
โโโ ๐ฟ main โโโโโโโโโโโโโโโโโโโโโโโโโโโโ Console Version
โ โโโ src/
โ โ โโโ TextFileManipulator.java # ๐ Main class โ entry point & all operations
โ โ โโโ LinkedList.java # ๐ Custom Singly LinkedList implementation
โ โ โโโ Stack.java # ๐ Custom Stack (array-based) implementation
โ โโโ sample.txt # ๐ Sample text file for testing
โ โโโ README.md # ๐ Project documentation
โ โโโ .gitignore # ๐ Git ignore rules
โ โโโ LICENSE # ๐ MIT License
โ
โโโ ๐ฟ gui-version โโโโโโโโโโโโโโโโโโโโโโโ JavaFX GUI Version
โโโ src/
โ โโโ TextFileManipulatorGUI.java # ๐จ Complete GUI โ single file (DSA included)
โโโ sample.txt # ๐ Sample text file for testing
โโโ .replit # โถ๏ธ Replit run configuration
โโโ README.md # ๐ GUI version documentation
โโโ .gitignore # ๐ Git ignore rules
โโโ LICENSE # ๐ MIT License
A custom Last-In-First-Out (LIFO) data structure implemented using an array. ๐
| Method | Description |
|---|---|
push(String x) |
โฌ๏ธ Add element to top |
pop() |
โฌ๏ธ Remove and return top element |
peek() |
๐๏ธ View top element without removing |
peekindex(int index) |
๐ Access element at a specific position |
stacksize() |
๐ Get current number of elements |
isEmpty() |
โ Check if stack is empty |
clearstack() |
๐งน Remove all elements |
display() |
๐จ๏ธ Print all elements |
Used for: ๐ Clipboard (copy/cut/paste), ๐ file content reversal, โ line insertion
A custom dynamic linear data structure using Node-based links. ๐
| Method | Description |
|---|---|
addFirst(String data) |
โฎ๏ธ Insert at head |
addLast(String data) |
โญ๏ธ Insert at tail |
delFirst() |
โ Delete head node |
deletefirstString() |
โ๏ธ Delete and return head data |
contains(String data) |
๐ Search for a value |
isEmpty() |
โ Check if list is empty |
Size() |
๐ Return total node count |
display() |
๐จ๏ธ Print all elements |
reverseAndWriteToFile(String path) |
๐ Reverse file using Stack |
Used for: ๐พ Storing file lines, ๐ซ duplicate removal, ๐ file merging, โ๏ธ๐ paste/cut operations
๐๏ธ Data Structures:
- ๐ Singly Linked List (insertion, deletion, traversal, searching)
- ๐ Stack using Array (push, pop, overflow & underflow handling)
- ๐๏ธ Array (used in sorting)
โก Algorithms:
- ๐ค Bubble Sort (on String array using
compareTo()) - ๐ Linear Search (for duplicate detection via
contains()) - ๐ LIFO-based reversal
โ Java Concepts:
- ๐ File I/O โ
BufferedReader,BufferedWriter,FileReader,FileWriter,RandomAccessFile - ๐งฉ Object-Oriented Programming โ Classes, Objects, Inner Classes (
Node) - ๐ Recursion โ Used in
checkname()for file validation - ๐ก๏ธ Exception Handling โ
try-catch,IOException,NoSuchElementException - ๐ String manipulation โ
contains(),compareTo(),equalsIgnoreCase()
- โ Java JDK 8 or above
- ๐ค Terminal / Command Prompt
# Step 1: Clone the repository
git clone https://github.com/Khansa972/Text-File-Manipulator.git
# Step 2: Navigate to src folder
cd Text-File-Manipulator/src
# Step 3: Compile all Java files
javac Stack.java LinkedList.java TextFileManipulator.java
# Step 4: Run the program
java TextFileManipulatorWhen the program asks for a file name, enter:
sample
โ ๏ธ Make suresample.txtis in the same folder where you runjava TextFileManipulator.
Switch to the
gui-versionbranch for full instructions.
# Switch to GUI branch
git checkout gui-version
# Navigate to src
cd src
# Compile
javac TextFileManipulatorGUI.java
# Run
java TextFileManipulatorGUIOr run directly on ๐ Replit โ see the gui-version branch README for steps.
---------------------------------------------------------------------------------
T E X T F I L E M A N I P U L A T O R
---------------------------------------------------------------------------------
Enter File Name in which you want changes :
> sample
Length of File : 120
------------------------------------------------------------------
PRESS :
(1). Eliminate repeated Lines from the file
(2). Reverse the content of file
(3). Insert new Line
(4). Copy text
(5). Paste text Line
(6). Cut the Line
(7). Sort the content of the file
(8). Write one file content to another file
(9). Exit
Khansa Bint-e-Zia
- ๐ GitHub: @Khansa972
- ๐ง Email: khansazia627@gmail.com
This project is licensed under the MIT License โ see the LICENSE file for details.