The ViaCEP Project is a Java application that interacts with the public ViaCEP API to obtain detailed address information based on the ZIP code provided by the user. The project's goal is to learn about API consumption with Java.
- Enter a ZIP code and obtain address details, including street, neighborhood, city, and state.
- Handle cases where the provided ZIP code is not found in the database and display appropriate error messages.
- Use the Gson library to parse JSON responses from the ViaCEP API into Java objects.
- Implement custom exceptions to handle specific errors and provide informative error messages.
To run the ViaCEP application, follow these steps:
- Clone the repository to your local machine using the command:
git clone https://github.com/camilazucchi/ViaCEP
- Open the project in your preferred Java development environment (e.g., IntelliJ IDEA, Eclipse, or Visual Studio Code).
- Ensure that the Gson library (com.google.code.gson) is added to the project's classpath. If not, download the Gson JAR file and include it in the project.
- Compile and execute the Main class to start the application.
- Start the ViaCEP application.
- Enter a valid Brazilian ZIP code when prompted.
- The application will connect to the ViaCEP API, retrieve address details, and display them in a structured format.
- If the ZIP code is not found in the database, an appropriate error message will be displayed.
- The application will also generate a JSON file named "address.json" containing the address details for the provided ZIP code.
The ViaCEP Project requires the following library:
- Gson (com.google.code.gson): A library for parsing JSON data into Java objects and vice versa.
Contributions to the ViaCEP Project are welcome. If you encounter any bugs, have suggestions for improvements, or want to add new features, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.