URLConnection (Java SE 23 & JDK 23)
-
Field Summary
Fields
protected booleanIf
true, thisURLis being examined in a context in which it makes sense to allow user interactions such as popping up an authentication dialog.protected booleanIf
false, this connection object has not created a communications link to the specified URL.protected booleanThis variable is set by the
setDoInputmethod.protected booleanThis variable is set by the
setDoOutputmethod.protected longSome protocols support skipping the fetching of the object unless the object has been modified more recently than a certain time.
protected URLThe URL represents the remote object on the World Wide Web to which this connection is opened.
protected booleanIf
true, the protocol is allowed to use caching whenever it can. -
Constructor Summary
Constructors
protectedConstructs a URL connection to the specified URL.
-
Method Summary
voidAdds a general request property specified by a key-value pair.
abstract voidconnect()Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.
booleanReturns the value of the
allowUserInteractionfield for this object.intReturns setting for connect timeout.
Retrieves the contents of this URL connection.
Retrieves the contents of this URL connection.
Returns the value of the
content-encodingheader field.intReturns the value of the
content-lengthheader field.longReturns the value of the
content-lengthheader field as a long.Returns the value of the
content-typeheader field.longgetDate()Returns the value of the
dateheader field.static booleanReturns the default value of the
allowUserInteractionfield.booleanReturns the default value of a
URLConnection'suseCachesflag.static booleanReturns the default value of the
useCachesflag for the given protocol.booleanReturns the value of this
URLConnection'sdoInputflag.booleanReturns the value of this
URLConnection'sdoOutputflag.longReturns the value of the
expiresheader field.Loads filename map (a mimetable) from a data file.
getHeaderField(int n) Returns the value for the
nth header field.Returns the value of the named header field.
longgetHeaderFieldDate(String name, long defaultValue) Returns the value of the named field parsed as date.
intgetHeaderFieldInt(String name, int defaultValue) Returns the value of the named field parsed as a number.
getHeaderFieldKey(int n) Returns the key for the
nth header field.longgetHeaderFieldLong(String name, long defaultValue) Returns the value of the named field parsed as a number.
Returns an unmodifiable Map of the header fields.
longReturns the value of this object's
ifModifiedSincefield.Returns an input stream that reads from this open connection.
longReturns the value of the
last-modifiedheader field.Returns an output stream that writes to this connection.
Returns a permission object representing the permission necessary to make the connection represented by this object.
intReturns setting for read timeout. 0 return implies that the option is disabled (i.e., timeout of infinity).
Returns an unmodifiable Map of general request properties for this connection.
Returns the value of the named general request property for this connection.
getURL()Returns the value of this
URLConnection'sURLfield.booleanReturns the value of this
URLConnection'suseCachesfield.Tries to determine the content type of an object, based on the specified "file" component of a URL.
Tries to determine the type of an input stream based on the characters at the beginning of the input stream.
voidsetAllowUserInteraction(boolean allowuserinteraction) Set the value of the
allowUserInteractionfield of thisURLConnection.voidsetConnectTimeout(int timeout) Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection.
static voidSets the
ContentHandlerFactoryof an application.static voidsetDefaultAllowUserInteraction(boolean defaultallowuserinteraction) Sets the default value of the
allowUserInteractionfield for all futureURLConnectionobjects to the specified value.static voidvoidsetDefaultUseCaches(boolean defaultusecaches) Sets the default value of the
useCachesfield to the specified value.static voidsetDefaultUseCaches(String protocol, boolean defaultVal) Sets the default value of the
useCachesfield for the named protocol to the given value.voidsetDoInput(boolean doinput) Sets the value of the
doInputfield for thisURLConnectionto the specified value.voidsetDoOutput(boolean dooutput) Sets the value of the
doOutputfield for thisURLConnectionto the specified value.static voidvoidsetIfModifiedSince(long ifmodifiedsince) Sets the value of the
ifModifiedSincefield of thisURLConnectionto the specified value.voidsetReadTimeout(int timeout) Sets the read timeout to a specified timeout, in milliseconds.
voidSets the general request property.
voidsetUseCaches(boolean usecaches) Sets the value of the
useCachesfield of thisURLConnectionto the specified value.toString()Returns a
Stringrepresentation of this URL connection.
-
Field Details
-
url
-
doInput
-
doOutput
-
allowUserInteraction
-
useCaches
-
ifModifiedSince
-
connected
-
-
Constructor Details
-
URLConnection
-
-
Method Details
-
getFileNameMap
-
setFileNameMap
-
connect
-
setConnectTimeout
-
getConnectTimeout
-
setReadTimeout
-
getReadTimeout
-
getURL
-
getContentLength
-
getContentLengthLong
-
getContentType
-
getContentEncoding
-
getExpiration
-
getDate
-
getLastModified
-
getContent
-
getContent
-
getPermission
-
getInputStream
-
getOutputStream
-
toString
-
setDoInput
-
getDoInput
-
setDoOutput
-
getDoOutput
-
setAllowUserInteraction
-
getAllowUserInteraction
-
setDefaultAllowUserInteraction
-
getDefaultAllowUserInteraction
-
setUseCaches
-
getUseCaches
-
setIfModifiedSince
-
getIfModifiedSince
-
getDefaultUseCaches
-
setDefaultUseCaches
-
setDefaultUseCaches
-
getDefaultUseCaches
-
setRequestProperty
-
addRequestProperty
-
getRequestProperty
-
getRequestProperties
-
setDefaultRequestProperty
-
getDefaultRequestProperty
-
setContentHandlerFactory
-
guessContentTypeFromName
-
guessContentTypeFromStream
-