Duplicate :
|
HttpURLConnection.getResponseCode throws FileNotFoundException if the HTTP response code is >=400. When calling HttpURLConnection.getResponseCode to obtain the HTTP response code, this method apparently invokes HttpURLConnection.getInputStream. However, getInputStream will throw an FileNotFoundException if the HTTP response code is >=400 and the URL does not end with either ".html", ".htm", "/" or ".txt". This problem prohibits us from using HttpURLConnection to connect to non-HTML based URL.
|