I am currently reading an XML file from a PHP script (as below) which works fine, however I’d now like to add some form of HTTP timeout to retrieving the XML.
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse("http://www.mywebsite.com/returnsXML");
Can this easily be added given my current approach, or would I need to change the request somehow to support timeouts?
You can open connection manually and set timeout for URLConnection: