Results 1 to 4 of 4
  1. #1
    aneuryzma is offline Member
    Join Date
    Aug 2008
    Posts
    46
    Rep Power
    0

    Default 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,

  2. #2
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    6

    Default

    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.

  3. #3
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    6

    Default

    :) 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

  4. #4
    Rooneyz is offline Member
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    25
    Rep Power
    0

    Default

    The way to do this is:

    Java Code:
    try
    {
           URL url = new URL("h.ttp://142.22.58.150/axis-cgi/mjpg/video.cgi");
    }catch(MalformedURLException nameOfTheException)
    {
           //put exceptioncode here 
    }
    This makes your program catch the exception. This exception migth occur when the file is missing on your filesystem.

Similar Threads

  1. java.net.MalformedURLException
    By mary in forum Advanced Java
    Replies: 1
    Last Post: 07-13-2007, 04:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •