Join Carlos Rivas for an in-depth discussion in this video Calling the API, part of Code Clinic: Java.
- [Instructor] Before we proceed,…make sure you have the starter project open,…which you can find in Exercise Files,…Starter Projects, Chapter 2.…You can open this folder in your favorite Java IDE.…In our case, we're using Visual Studio Code.…So let's open it up and take a look.…In our program, the getData function…is our primary method that we'll use…to connect to our IP geolocation provider,…seen here on line 28.…
Let's expand that.…First thing worth noting…is that you can pass an empty string…or a valid IP address.…If you pass an empty string,…IP info will use your current IP address…to generate the result.…Once we complete our URL call,…seen here on line 37,…we scan the output line by line…and then close our buffer reader.…The scan happens inside the while loop…seen here on line 44.…
Finally, the string variable response…contains our desired values,…seen here on line 45.…The resulting JSON document is returned back…to our main function in the form of a string,…seen here on line 55.…At this point,…our job is to parse a response…
Visit other courses in the series to see how to solve the exact same challenges in languages like C#, C++, PHP, Python, and Ruby.
Skill Level Intermediate
1. Problem 1: Pond Oreille
2. Problem 2: Where Am I?
3. Problem 3: Eight Queens
4. Problem 4: Accessing Peripherals
5. Problem 5: Facial Recognition
6. Problem 6: Real-Time Information Dashboard
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.