Matlab using Java openStream(url) get :Java exception occurred: java.lang.NullPointerException
古いコメントを表示
Hi,
I want to download one file from a URL. 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.
Anyone can help? thanks
12 件のコメント
Geoff Hayes
2014 年 11 月 20 日
buer - what happens on the previous line
jurl = java.net.URL(linki);
What is linki? Is it a valid URL? I ran the code with a couple of test URLs and was able to download each without any problems.
buer
2014 年 11 月 21 日
Geoff Hayes
2014 年 11 月 21 日
Have you verified that the link that you build, linki, is valid? i.e. can you copy and paste it into your browser and view the file?
As for needing a username and password, that could be the problem...
buer
2014 年 11 月 24 日
Geoff Hayes
2014 年 11 月 25 日
An alternative to this code may be to use webread or urlread. The first function can be used if you have R2014b. Both seem to allow for username and passwords. See also http://www.mathworks.com/matlabcentral/answers/161160-urlread-vs-view-source-need-view-source-data which may be useful.
buer
2014 年 11 月 25 日
Geoff Hayes
2014 年 11 月 25 日
You may be able to urlread...it should be a function that your version of MATLAB has.
buer
2014 年 12 月 1 日
Geoff Hayes
2014 年 12 月 2 日
Hi Buer - have you verified that links is valid?
buer
2014 年 12 月 2 日
Geoff Hayes
2014 年 12 月 2 日
Buer - good that you figured it out. Could you summarize it as an answer below?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Introduction to Installation and Licensing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!