- java.lang.Object
-
- jakarta.activation.URLDataSource
-
- All Implemented Interfaces:
DataSource
public class URLDataSource extends java.lang.Object implements DataSource
The URLDataSource class provides an object that wraps aURLobject in a DataSource interface. URLDataSource simplifies the handling of data described by URLs within Jakarta Activation 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:
DataSource,DataHandler
-
-
Constructor Summary
Constructors Constructor Description URLDataSource(java.net.URL url)URLDataSource constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetContentType()Returns the value of the URL content-type header field.java.io.InputStreamgetInputStream()The getInputStream method from the URL.java.lang.StringgetName()Calls thegetFilemethod on the URL used to instantiate the object.java.io.OutputStreamgetOutputStream()The getOutputStream method from the URL.java.net.URLgetURL()Return the URL used to create this DataSource.
-
-
-
Method Detail
-
getContentType
public java.lang.String getContentType()
Returns the value of the URL content-type header field. It calls the URL'sURLConnection.getContentTypemethod after retrieving a URLConnection object. Note: this method attempts to call theopenConnectionmethod 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.- Specified by:
getContentTypein interfaceDataSource- Returns:
- the content type.
-
getName
public java.lang.String getName()
Calls thegetFilemethod on the URL used to instantiate the object.- Specified by:
getNamein interfaceDataSource- Returns:
- the result of calling the URL's getFile method.
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOExceptionThe getInputStream method from the URL. Calls theopenStreammethod on the URL.- Specified by:
getInputStreamin interfaceDataSource- Returns:
- the InputStream.
- Throws:
java.io.IOException- for failures creating the InputStream
-
getOutputStream
public java.io.OutputStream getOutputStream() throws java.io.IOExceptionThe 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.- Specified by:
getOutputStreamin interfaceDataSource- Returns:
- the OutputStream.
- Throws:
java.io.IOException- for failures creating the OutputStream
-
getURL
public java.net.URL getURL()
Return the URL used to create this DataSource.- Returns:
- The URL.
-
-