Advertisement
rjsantiago0001

queryOpenWeatherMap

Aug 4th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.net.MalformedURLException;
  3. import net.aksingh.owmjapis.CurrentWeather;
  4. import net.aksingh.owmjapis.OpenWeatherMap;
  5. import org.json.JSONException;
  6.  
  7. public class WeatherExample {
  8.  
  9.     public static void main(String[] args)
  10.             throws IOException, MalformedURLException, JSONException {
  11.  
  12.         // declaring object of "OpenWeatherMap" class
  13.         OpenWeatherMap owm = new OpenWeatherMap("ea950a82a1470f29811e9fe0592d6afa");
  14.  
  15.         // getting current weather data for the "London" city
  16.         CurrentWeather cwd = owm.currentWeatherByCityName("Southwick");
  17.  
  18.         //printing city name from the retrieved data
  19.         System.out.println("City: " + cwd.getCityName());
  20.  
  21.         // printing the max./min. temperature
  22.         System.out.println("Temperature: " + cwd.getMainInstance().getMaxTemperature()
  23.                             + "/" + cwd.getMainInstance().getMinTemperature() + "\'F");
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement