很简单,举例如下:
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection()
urlConnection.setRequestMethod("GET")
urlConnection.setDoOutput(false)
urlConnection.setConnectTimeout(10 * 1000)
urlConnection.setReadTimeout(10 * 1000)
urlConnection.setRequestProperty("Connection", "Keep-Alive")
String username = "[username]"
String password = "[password]"
String input = username + ":" + password
String encodingInput = Base64.encodeToString(input.getBytes(), 0)
urlConnection.connect()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)