Reputation: 21
Using Kotlin, I'm trying to access an URL that is blocked in my country and I need to change the DNS or turn on VPN to make a successful connection.
Is there any way to change the DNS programmatically, or is there any other suitable solution to this problem.
My code:
val url = URL("https://prices2.herokuapp.com/")
val con=url.openConnection() as HttpURLConnection
con.connectTimeout=5000
val inputstream=con.inputStream
val bufferreader=BufferedReader(InputStreamReader(inputstream))
bufferreader.forEachLine {
data+=it
}
Upvotes: 1
Views: 675