Results 1 to 4 of 4
- 08-13-2008, 09:42 PM #1
Member
- Join Date
- Aug 2008
- Posts
- 46
- Rep Power
- 0
why do I get java.net.MalformedURLException ?
This is my code:
(The class BoundaryMJPEGConnection wants an InputStream)
{code}
URL url = new URL("h.ttp://142.22.58.150/axis-cgi/mjpg/video.cgi");
(NB I added "." after h because the forum does not let me to post urls)
BoundaryMJPEGConnection bMconnection = new BoundaryMJPEGConnection( url.openStream());
{code}
I got the following error:
unreported exception java.net.MalformedURLException; must be caught or declared to be thrown
URL url = new URL("h.ttp://142.22.58.150/axis-cgi/mjpg/video.cgi");
^
1 error
thanks,
- 08-13-2008, 10:16 PM #2
You are not getting the exception, you are being told that you must catch it.
The API says that that constructor can throw an exception, its your job to catch it.
- 08-14-2008, 07:50 AM #3
:) yes fishPhotoRecords is right...
and even after that remove "." in "h.ttp" or it may not work correctly.To finish sooner, take your own time....
Nivedithaaaa
- 08-14-2008, 11:57 AM #4
Member
- Join Date
- Aug 2008
- Location
- The Netherlands
- Posts
- 25
- Rep Power
- 0
The way to do this is:
This makes your program catch the exception. This exception migth occur when the file is missing on your filesystem.Java Code:try { URL url = new URL("h.ttp://142.22.58.150/axis-cgi/mjpg/video.cgi"); }catch(MalformedURLException nameOfTheException) { //put exceptioncode here }
Similar Threads
-
java.net.MalformedURLException
By mary in forum Advanced JavaReplies: 1Last Post: 07-13-2007, 04:37 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks