Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > going back from catch to try-webspider

Reply
Thread Tools

going back from catch to try-webspider

 
 
ameerov@gmail.com
Guest
Posts: n/a
 
      11-18-2005
I'm writing a webspider. When a bad url is encountered then a
MalformedURLException is thrown. What I want to do is ignore this bad
URL's exception and continue reading the other urls.

I'm not very familiar with try catch blocks but as I understand there
is no way to go from catch BACK TO the try .(After encountering an
exception)

So then how is it possible to ignore this exception and thus SKIP
reading the bad URL so I can continue reading the good ones ?

Thanks.

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      11-18-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> I'm writing a webspider. When a bad url is encountered then a
> MalformedURLException is thrown. What I want to do is ignore this bad
> URL's exception and continue reading the other urls.
>
> I'm not very familiar with try catch blocks but as I understand there
> is no way to go from catch BACK TO the try .(After encountering an
> exception)


It depends, if the try/catch is entirely inside a loop, the
loop itself can continue.

A better group for those new to Java is
<http://www.physci.org/codes/javafaq.jsp#cljh>

--
Andrew Thompson
physci, javasaver, 1point1c, lensescapes - athompson.info/andrew
Currently accepting short and long term contracts - on Earth.
 
Reply With Quote
 
 
 
 
Bjorn Abelli
Guest
Posts: n/a
 
      11-18-2005

<(E-Mail Removed)> wrote...

> I'm writing a webspider. When a bad url is encountered
> then a MalformedURLException is thrown. What I want to
> do is ignore this bad URL's exception and continue reading
> the other urls.
>
> I'm not very familiar with try catch blocks but as I
> understand there is no way to go from catch BACK TO
> the try .(After encountering an exception)
>
> So then how is it possible to ignore this exception and
> thus SKIP reading the bad URL so I can continue reading
> the good ones ?


That depends on your specific implementation.

Lets say that you have all urls as strings in a list of some sort.

Then you iterate through them somehow, e.g:

for (int i = 0; i < numberOfUrls; i++)
{
String url = (String) listOfUrls.get(i);

try
{
// Some parsing or whatever, that can
// throw a MalformedURLException

// Here you proceed on the urls that hasn't
// thrown a MalformedURLException
}
catch (MalformedURLException mux)
{
// Here you do whatever you want, e.g.
// write the String url to a logfile, to
// check at a later time.
}
}

// Bjorn A


 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      11-18-2005
On 18 Nov 2005 07:05:38 -0800, (E-Mail Removed) wrote, quoted or
indirectly quoted someone who said :

>So then how is it possible to ignore this exception and thus SKIP
>reading the bad URL so I can continue reading the good ones ?


you put a try block around the whole thing so if anything fails it
jumps to the end.
where you can do a finally close.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
catch doesn't catch a thrown exception Marteno Rodia Java 5 08-05-2009 03:30 AM
Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up." Midex Python 24 05-07-2007 04:23 AM
catch(...) doesn't catch everything Adam C++ 9 02-02-2006 05:02 PM
why catch (...) can not catch such exception John Black C++ 8 08-20-2004 02:34 PM
VPN going up but traffic going one way PLP Cisco 1 07-11-2003 08:28 AM



Advertisments