Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
|
||
/** | ||
* | ||
* @author Data | ||
*/ | ||
public class JavaApplication3 { | ||
|
||
/** | ||
* @param url | ||
* @throws java.io.IOException | ||
*/ | ||
|
||
// This allows to integrate teh api in Java... ! | ||
// Looks good. | ||
public void networking(String url) throws IOException{ | ||
URL urls; | ||
urls = new URL("http://api.openweathermap.org/data/2.5/weather?APPID=d98cf0f33972375849da99fef900c4f8&units=metric&q=london"); | ||
HttpURLConnection con = (HttpURLConnection) urls.openConnection(); | ||
con.setRequestMethod(" HttpURLConnection con = (HttpURLConnection) urls.openConnection();GET"); | ||
BufferedReader sampleBufferReader; | ||
sampleBufferReader = new BufferedReader(new InputStreamReader(con.getInputStream())); | ||
// String buffer - need to study about what string buffer is ? | ||
|
||
String inputLine; | ||
StringBuilder content = new StringBuilder(); | ||
|
||
while((inputLine = sampleBufferReader.readLine()) != null){ | ||
content.append(inputLine); | ||
} | ||
sampleBufferReader.close(); | ||
System.out.println(content); | ||
} | ||
|
||
public static void main(String[] args) throws IOException { | ||
// TODO code application logic here | ||
JavaApplication3 javaT = new JavaApplication3(); | ||
javaT.networking(""); | ||
} | ||
|
||
} |