public class

URLDataSource

extends Object
implements DataSource
java.lang.Object
   ↳ com.google.code.javax.activation.URLDataSource

Class Overview

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

Summary

Fields
private URL url
private URLConnection url_conn
Public Constructors
URLDataSource(URL url)
URLDataSource constructor.
Public Methods
String getContentType()
Returns the value of the URL content-type header field.
InputStream getInputStream()
The getInputStream method from the URL.
String getName()
Calls the getFile method on the URL used to instantiate the object.
OutputStream getOutputStream()
The getOutputStream method from the URL.
URL getURL()
Return the URL used to create this DataSource.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.code.javax.activation.DataSource

Fields

private URL url

private URLConnection url_conn

Public Constructors

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 The URL to be encapsulated in this object.

Public Methods

public String 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
  • the content type.

public InputStream getInputStream ()

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

Returns
  • the InputStream.
Throws
IOException

public String getName ()

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

Returns
  • the result of calling the URL's getFile method.

public OutputStream 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
  • the OutputStream.
Throws
IOException

public URL getURL ()

Return the URL used to create this DataSource.

Returns
  • The URL.