Added osu!Mirror download server.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han
2015-05-07 23:58:04 -04:00
parent 50d55d8d99
commit cab207e275
6 changed files with 268 additions and 69 deletions

View File

@@ -51,6 +51,8 @@ import java.util.Scanner;
import javax.imageio.ImageIO;
import org.json.JSONException;
import org.json.JSONObject;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
@@ -554,6 +556,25 @@ public class Utils {
}
}
/**
* Returns a JSON object from a URL.
* @param url the remote URL
* @return the JSON object
* @author Roland Illig (http://stackoverflow.com/a/4308662)
*/
public static JSONObject readJsonFromUrl(URL url) throws IOException {
String s = Utils.readDataFromUrl(url);
JSONObject json = null;
if (s != null) {
try {
json = new JSONObject(s);
} catch (JSONException e) {
ErrorHandler.error("Failed to create JSON object.", e, true);
}
}
return json;
}
/**
* Converts an input stream to a string.
* @param is the input stream