A set of Java utilities to work with directories, text files, and object serialization, implemented with a simple MVC pattern
The project is divided en 3 parts:
The first one are FileManager and the DirectoryManager classes who are under the package model. FileManager is used for managing files and for reading and writing in them. DirectoryManager is used for managing folders, get information like date creation and for ordering them.
Under the package view we have FileView and DirectoryView, originally they didn't exist but I decided to separate the management from the user interaction. Fileview is the user interface class for FileManager and DirectoryView is the user interace class for DirectoryManager.
At last, outside the level1 and level 2 packages we have the solutions for everyone of the 6 exercicies, instead of a single Main I decided to make a main for every one of them, for making them more easy to read.
You can use any carpet from your system to use the program, even any file inside the carpet. The program will ask you for the route for managing a specific folder and the files inside of it.
- Exercise 1 β List contents of a directory alphabetically.
- Exercise 2 β Recursively list a directory tree with type (D/F) and last modification date.
- Exercise 3 β Save the directory tree to a
.txtfile. - Exercise 4 β Read any
.txtfile and display its content on the console. - Exercise 5 β Serialize a directory object to
.serand deserialize it back.
src/ ββ main/ β ββ java/ β β ββ model/ β β β ββ DirectoryManager.java β β β ββ FileManager.java β β β ββ SerDesDirectory.java β β ββ view/ β β β ββ DirectoryView.java β β β ββ FileView.java β β ββ level1/ β β ββ Ex1.java β β ββ Ex2.java β β ββ Ex3.java β β ββ Ex4.java β β ββ Ex5.java ββ resources/ ββ config.properties
Optional: you can configure the directory and output file using config.properties:
properties: directoryPath=newFolder outputFile=directoryTree.txt recursive=true
This project contains exercises for working with directories and files in Java.
- Build the project with Maven:
bash mvn clean package
-
Navigate to compiled classes: cd target/classes
-
Run any main class: java level1.Ex1 # Exercise 1 java level1.Ex2 # Exercise 2 java level1.Ex3 # Exercise 3 java level1.Ex4 # Exercise 4 java level1.Ex5 # Exercise 5