I want to download one file from a URL using Matlab.
According to this: http://www.mathworks.com/matlabcentral/newsreader/view_thread/294528. all works fine until i go to the line:
is = jurl.openStream;
This gave one error says Java exception occurred: java.lang.NullPointerException.
Edit:
Company='Abc';
Depar='Fin';
url1='com/';;
url2='/download_h5_Depar=';
url3='.h5' ;
url=strcat(url1,Company,url2,Depar,url3);
links=url;
% copy files to local folder
[pathstr, name, ext ] = fileparts(links);
% name changed here
name=strcat(Company,'-',Depar);
Error message:
at com.mathworks.net.transport.MWTransportClientPropertiesFactory$1.getPasswordAuthentication(MWTransportClientPropertiesFactory.java:86)
at java.net.Authenticator.requestPasswordAuthentication(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$1.run(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.privilegedRequestPasswordAuthentication(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getServerAuthentication(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
Anyone can help? thanks