One rule
Your CLI should treat files as input, not as your program’s memory. Read data at the edge, convert it into Java objects, then let the rest of your code work with those objects.
Why JSON here
For this recruiter project, JSON is a good sample data format. It is readable, common in APIs, and easy for another builder to edit before running your app.
Use it for things like candidates, jobs, skills, cities, expected salary, or application status. Keep the file small enough to understand in one screen.
Sample data file
Place sample files in a clear folder like data/. Do not hide them inside random package folders.
Example: data/candidates.json
[
{
"id": 1,
"name": "Asha Nair",
"city": "Kochi",
"skills": ["Java", "SQL", "Git"],
"expectedSalaryLpa": 6.0
},
{
"id": 2,
"name": "Rohit Sharma",
"city": "Pune",
"skills": ["Java", "Spring", "PostgreSQL"],
"expectedSalaryLpa": 8.5
}
]Reading files safely
In Java, use Path and Files from java.nio.file for normal file work. They are cleaner than old File code for most CLI apps.
Start with plain file reading. Then parse the JSON using a library such as Jackson or Gson once your build lesson adds dependencies.
Read a JSON file
This method reads the full file into a String. Your JSON parser can use that string later.
It also gives a clear error if the file is missing, which is better than a long stack trace during a demo.
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class JsonFileReader {
public static String readJson(String filePath) {
Path path = Path.of(filePath);
if (!Files.exists(path)) {
throw new IllegalArgumentException("File not found: " + filePath);
}
try {
return Files.readString(path);
} catch (IOException e) {
throw new RuntimeException("Could not read file: " + filePath, e);
}
}
}
// Usage:
// String json = JsonFileReader.readJson("data/candidates.json");Avoid hard-coded data
A common beginner mistake is creating all candidates inside main(). That makes your project look like a coding exercise, not a usable CLI tool.
Keep two or three sample records in JSON. Let the user pass the file path later, or keep a sensible default like data/candidates.json.
Check AI output
If you ask an AI tool to create sample JSON, check three things before committing it: valid JSON syntax, realistic field names, and data that matches your Java class names and types.
For example, do not let one record use expectedSalary and another use expectedSalaryLpa unless your parser is built for that.
Do this now
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 5 done