Prev: dir function and my poor numbering system
Next: Question on ML04 Calculator Exercises from Mathworks Training Services
From: Leonardo on 2 Feb 2010 17:48 I'm try to retrieve data from several web addresses. I set a for loop and for each single loop I build the URL string and then pass it to the following code: buffer= java.io.BufferedReader(... java.io.InputStreamReader(... openStream(... java.net.URL(url_string)))); If the URL is not available I get an error (Java exception occurred:) and then the loop stops. Is there a way I can capture the error and avoid the loop to stop but just move to the next URL? Thanks Leonardo
From: Yair Altman on 3 Feb 2010 17:36
"Leonardo " <leopetz(a)hotmail.com> wrote in message <hkaa32$547$1(a)fred.mathworks.com>... > I'm try to retrieve data from several web addresses. I set a for loop and for each single loop I build the URL string and then pass it to the following code: > > buffer= java.io.BufferedReader(... > java.io.InputStreamReader(... > openStream(... > java.net.URL(url_string)))); > > If the URL is not available I get an error (Java exception occurred:) and then the loop stops. Is there a way I can capture the error and avoid the loop to stop but just move to the next URL? > > Thanks > Leonardo simply place your code within a try-catch-end block: while (loopCondition) try buffer = java.io.BufferedReader(...); catch % next URL please... end % try URL end % loop Yair Altman http://UndocumentedMatlab.com |