Possible Duplicate:
Java HttpURLConnection
Would this method be used for example if I want to read the response to a POST method call from the server I am connected to?
setDoInput(true) is used to fetch the response and is true by default. When using a different method e.g. GET, you have nothing to pass to the connection, so an OutputStream is not necessary.
URLConnection is the base class. HttpURLConnection is a derived class which you can use when you need the extra API and you are dealing with HTTP or HTTPS only. HttpsURLConnection is a 'more derived' class which you can use when you need the 'more extra' API and you are dealing with HTTPS only.
getContentType. Returns the value of the content-type header field. Returns: the content type of the resource that the URL references, or null if not known.
The abstract class URLConnection is the superclass of all classes that represent a communications link between the application and a URL. Instances of this class can be used both to read from and to write to the resource referenced by the URL.
I've never encountered a case for setting it false. You always want to read something, at least the response code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With