download

fun download(url: String, action: (HttpURLConnection) -> Unit = {}): InputStream?

Helper opens am url and accesses its input stream, logging errors to the console

Return

The InputStream if successful, null otherwise.

Parameters

url

String representing a URL to download.

action

Optional callback that will be executed between opening the connection and accessing its data - passes the connection and allows e.g. reading the response headers.

Sources

jvm source
Link copied to clipboard