Top Description Fields Constructors Methods
javax.activation

public Class URLDataSource

extends Object
implements DataSource
Class Inheritance
All Implemented Interfaces
javax.activation.DataSource
Imports
java.net.URL, .URLConnection, java.io.InputStream, .OutputStream, .IOException

The URLDataSource class provides an object that wraps a URL object in a DataSource interface. URLDataSource simplifies the handling of data described by URLs within the JavaBeans Activation Framework because this class can be used to create new DataHandlers.

Note

The DataHandler object creates a URLDataSource internally, when it is constructed with a URL.

See Also
javax.activation.DataSource, javax.activation.DataHandler

Field Summary

Modifier and TypeField and Description
private URL
private URLConnection

Constructor Summary

AccessConstructor and Description
public
URLDataSource(URL
The URL to be encapsulated in this object.
url
)

URLDataSource constructor.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the content type.
getContentType
()

Implements javax.activation.DataSource.getContentType.

Returns the value of the URL content-type header field.
public InputStream

Returns:

the InputStream.
getInputStream
()

Implements javax.activation.DataSource.getInputStream.

The getInputStream method from the URL.
public String

Returns:

the result of calling the URL's getFile method.
getName
()

Implements javax.activation.DataSource.getName.

Calls the getFile method on the URL used to instantiate the object.
public OutputStream

Returns:

the OutputStream.
getOutputStream
()

Implements javax.activation.DataSource.getOutputStream.

The getOutputStream method from the URL.
public URL

Returns:

The URL.
getURL
()

Return the URL used to create this DataSource.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

urlback to summary
private URL url
url_connback to summary
private URLConnection url_conn

Constructor Detail

URLDataSourceback to summary
public URLDataSource(URL url)

URLDataSource constructor. The URLDataSource class will not open a connection to the URL until a method requiring it to do so is called.

Parameters
url:URL

The URL to be encapsulated in this object.

Method Detail

getContentTypeback to summary
public String getContentType()

Implements javax.activation.DataSource.getContentType.

Returns the value of the URL content-type header field. It calls the URL's URLConnection.getContentType method after retrieving a URLConnection object.

Note

this method attempts to call the openConnection method on the URL. If this method fails, or if a content type is not returned from the URLConnection, getContentType returns "application/octet-stream" as the content type.

Returns:String

the content type.

getInputStreamback to summary
public InputStream getInputStream() throws IOException

Implements javax.activation.DataSource.getInputStream.

The getInputStream method from the URL. Calls the openStream method on the URL.

Returns:InputStream

the InputStream.

Exceptions
IOException:

Doc from javax.activation.DataSource.getInputStream.

for failures creating the InputStream

getNameback to summary
public String getName()

Implements javax.activation.DataSource.getName.

Calls the getFile method on the URL used to instantiate the object.

Returns:String

the result of calling the URL's getFile method.

getOutputStreamback to summary
public OutputStream getOutputStream() throws IOException

Implements javax.activation.DataSource.getOutputStream.

The getOutputStream method from the URL. First an attempt is made to get the URLConnection object for the URL. If that succeeds, the getOutputStream method on the URLConnection is returned.

Returns:OutputStream

the OutputStream.

Exceptions
IOException:

Doc from javax.activation.DataSource.getOutputStream.

for failures creating the OutputStream

getURLback to summary
public URL getURL()

Return the URL used to create this DataSource.

Returns:URL

The URL.