java.net.URLConnection.getContent()
Philip Race
philip.race at oracle.com
Fri Jun 13 22:11:36 UTC 2025
java.net.URLConnection has
public Object getContent();
It uses the desktop module to find handlers for image and audio data
Briefly, the desktop module
"provides java.net.ContentHandlerFactory with
sun.awt.www.content.MultimediaContentHandlers;"
That knows about several audio and image mime types.
And URLConnection passes a mimetype string to the ContentHandlerFactory
If it is one of the mimetypes known to the desktop provider
URLConnection gets returned one of
URLImageSource
java.awt.Image
java.applet.AudioClip
But the return type of getContent() is just java.lang.Object and nothing
is specified.
How does anything use this API ?
The reason this comes up is that when removing the Applet API, this
needs to transition to something
other than AudioClip - but who would notice if it got back null instead
? Or just a byte[] of the raw data ?
Or something else ?
Is this API actually used ? Or useful ?
-phil
More information about the net-dev
mailing list