Skip to content

Instantly share code, notes, and snippets.

@WinXaito
Last active October 14, 2015 16:26
Show Gist options
  • Save WinXaito/d0557ad607d8bf4e89ee to your computer and use it in GitHub Desktop.
Save WinXaito/d0557ad607d8bf4e89ee to your computer and use it in GitHub Desktop.
Erreur 500 API membres ZDS
package com.winxaito.main;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
public class Main {
public static void main(String[] args) {
try {
URL url = new URL("https://api.github.com/users/winxaito");
String content = "", line = null;
System.out.println("Authority : " + url.getAuthority());
System.out.println("Default port : " + url.getDefaultPort());
System.out.println("Host : " + url.getHost());
System.out.println("Port : " + url.getPort());
System.out.println("Protocol : " + url.getProtocol());
try {
URLConnection urlConn = url.openConnection();
System.out.println("ContentType : " + urlConn.getContentType() + "\n");
BufferedReader buf = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
while((line = buf.readLine()) != null){
content += line + "\n";
}
System.out.println("RESULT:" + content);
} catch (IOException e) {
e.printStackTrace();
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment