Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- private static String readAll(Reader rd) throws IOException {
- StringBuilder sb = new StringBuilder();
- int cp;
- while ((cp = rd.read()) != -1) {
- sb.append((char) cp);
- }
- return sb.toString();
- }
- public static JSONObject readJsonFromUrl(String url) throws IOException, JSONException {
- InputStream is = new URL(url).openStream();
- try {
- BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
- String jsonText = readAll(rd);
- JSONObject json = new JSONObject(jsonText);
- return json;
- } finally {
- is.close();
- }
- }
- public static void main(String[] args) throws IOException, JSONException {
- JSONObject json = readJsonFromUrl("http://status.mojang.com/check");
- System.out.println(json.toString());
- System.out.println(json.get("minecraft.net"));
- System.out.println(json.toString());
- System.out.println(json.get("login.minecraft.net"));
- System.out.println(json.toString());
- System.out.println(json.get("session.minecraft.net"));
- System.out.println(json.toString());
- System.out.println(json.get("account.mojang.com"));
- System.out.println(json.toString());
- System.out.println(json.get("auth.mojang.com"));
- System.out.println(json.toString());
- System.out.println(json.get("skins.minecraft.com"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement