I have an instance method, and inside it I did a simple analysis of web pages:
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{}
}
Since I am currently hard-coded the server address in the string, there may be situations where the server name is incorrect, so in this case I want it to automatically change the server URL string to "localhost".
I think the if-else statement will probably work, but I'm not very sure how to define a boolean to determine if this parsing was unsuccessful or not. I also think about putting this in a catch statement, but what about other statements throwing exceptions as well?
API DocumentBuilder, parse() , . , - , URL- , , .