http - Read remote file from java code which is password protected -


i want read file in remote location througt http protocal, tried basic auth not working, when access througt browser ask me user id password , when give correct 1 opens file in chrome browser.

i used following code

url url = new url(“location address”); urlconnection uc = url.openconnection(); string userpass = username + ":" + password"; string basicauth = "basic " + new string(new base64().encode(userpass.getbytes())); uc.setrequestproperty ("authorization", basicauth); inputstream in = uc.getinputstream(); 

cheers


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -