Networking utilities
Getting a string response from a URL
String url = "https://example.com";
String userAgent = "Example/1.0.0";
int timeout = 30_000; // 30 seconds
boolean useCaches = true; // If we request from this same URL multiple times, the response will be cached
String response = NetworkUtils.getString(url, userAgent, timeout, useCaches);
System.out.println("Response from example.com:\n" + response);val url = "https://example.com"
val userAgent = "Example/1.0.0"
val timeout = 30_000 // 30 seconds
val useCaches = true // If we request from this same URL multiple times, the response will be cached
val response = NetworkUtils.getString(url, userAgent, timeout, useCaches)
println("Response from example.com:\n$response")String url = "https://example.com";
String response = NetworkUtils.getString(url);
System.out.println("Response from example.com:\n" + response);val url = "https://example.com"
val response = NetworkUtils.getString(url)
println("Response from example.com:\n$response")Getting a JSON response from a URL
String url = "https://example.com";
JsonElement json = JsonUtils.parseFromUrl(url);
// You can use your JsonElement as you pleaseval url = "https://example.com"
val json: JsonElement = JsonUtils.parseFromUrl(url)
// You can use your JsonElement as you pleaseDownloading files
Opening a link in the user's default browser
Last updated