ZipFinder is a simple Java console application that allows users to search for Brazilian ZIP codes (CEP) or addresses using the ViaCEP API. The user can enter a ZIP code or an address (state, city, street), and the application will fetch the corresponding address or ZIP code and save the results to a file.
- Search for a Brazilian address by ZIP code.
- Search for a ZIP code by providing an address.
- Save the search results to a customizable file.
- Java 22
- IntelliJ IDEA (or another Java IDE)
- Gson library (Download the
gson-*.jar
file)
- Download the
gson-*.jar
file from the Gson GitHub releases page. - Open IntelliJ IDEA and create a new Java project.
- Add the
gson-*.jar
file to your project's classpath:- Go to
File
>Project Structure
>Modules
>Dependencies
. - Click
+
>JARs or Directories
and select thegson-*.jar
file.
- Go to
- In IntelliJ, open
Main.java
. - Run the
main
method using the green play button or by right-clicking and selectingRun 'Main.main()'
.
Upon running the application, you'll be presented with a menu:
Want to find out a Brazilian ZIP code or address? 1- Zip code 2- Address 3- Leave
- Select the option to search by ZIP code.
- Enter the ZIP code you want to search for.
- The application will fetch the corresponding address and prompt you to save the result to a file.
- Select the option to search by address.
- Enter the state (e.g., SP, MG).
- Enter the city.
- Enter the street or avenue name (without a complement) (e.g., Avenida Paulista).
- The application will fetch the corresponding ZIP code(s) and prompt you to save the result to a file.
After a search, you'll have the option to save the results to a file. By default, the file will be saved in the current directory as ZipFinder-Address.txt
. You can also customize the file name and path.
Main.java
: Entry point of the application.Menu.java
: Handles the user interface and input.Search.java
: Manages the API requests and responses.AddressWriter.java
: Handles writing the search results to a file.Address.java
: Represents an address object.