A question about exception catching in Java
<p>I have an instance method, and within it, I did a simple webpage parsing:</p>

<pre><code>public void doOperation(final AuthorAccess authorAccess, ArgumentsMap arguments) throws  IllegalArgumentException,AuthorOperationException
{

    final String server = "chiexist1.worldbook.com";
    final String port = "8080";
    try {

             docBuilder = docFactory.newDocumentBuilder();
             doc = docBuilder.parse("http://" + server + ":" + port + "/exist/webdav/db/portfolio/config/products.xml");
        ...}
       catch{}
  }
</code></pre>

<p>Because currently I am hard-coding the server address in the string, there might be situations where the server name is not right, so in that case, I want it to automatically to change the server URL string to "localhost".</p>

<p>I think an if-else statement probably would work, but I am not very sure how to determine the boolean variable for detecting whether this parsing is failed or not. I also think of putting this in the catch statement, but what about other statements are also throwing exceptions?</p>

<p>I've also checked the API for DocumentBuilder, the parse() method always return a Document Type but not boolean. So I would be grateful if anyone could give me some suggestions here on how to detect the wronged URL and then change to parsing localhost instead, thanks in advance.</p>
