This is a major problem, becuase of the behaivor of the getInputStream() methods on the same classes. These methods throw a FileNotFoundException if the HTTP response code is >= 400. Nearly every web server in existence returns a document along with an error code -- for example, if the error code is 404, the document usually says "Document not found", and generally includes the e-mail address of the webmaster, and possibly other useful information. Sometimes this document even indicates that a search returned no matches. In any case, it is often important that this "error" document is made available to the user -- but there is NO WAY to get this document using the URLConnection classes.
Partager