- java.lang.Object
-
- javax.activation.URLDataSource
-
- All Implemented Interfaces:
- DataSource
public class URLDataSource extends Object implements DataSource
The URLDataSource class provides an object that wraps aURL
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.- Since:
- 1.6
- See Also:
DataSource
,DataHandler
-
-
Constructor Summary
Constructors Constructor and Description URLDataSource(URL url)
URLDataSource constructor.
-
Method Summary
Methods Modifier and Type Method and Description String
getContentType()
Returns the value of the URL content-type header field.InputStream
getInputStream()
The getInputStream method from the URL.String
getName()
Calls thegetFile
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.
-
-
-
Constructor Detail
-
URLDataSource
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.
-
-
Method Detail
-
getContentType
public String getContentType()
Returns the value of the URL content-type header field. It calls the URL'sURLConnection.getContentType
method after retrieving a URLConnection object. Note: this method attempts to call theopenConnection
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.- Specified by:
getContentType
in interfaceDataSource
- Returns:
- the content type.
-
getName
public String getName()
Calls thegetFile
method on the URL used to instantiate the object.- Specified by:
getName
in interfaceDataSource
- Returns:
- the result of calling the URL's getFile method.
-
getInputStream
public InputStream getInputStream() throws IOException
The getInputStream method from the URL. Calls theopenStream
method on the URL.- Specified by:
getInputStream
in interfaceDataSource
- Returns:
- the InputStream.
- Throws:
IOException
-
getOutputStream
public OutputStream getOutputStream() throws IOException
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.- Specified by:
getOutputStream
in interfaceDataSource
- Returns:
- the OutputStream.
- Throws:
IOException
-
getURL
public URL getURL()
Return the URL used to create this DataSource.- Returns:
- The URL.
-
-
Document created the 11/06/2005, last modified the 04/03/2020
Source of the printed document:https://www.gaudry.be/en/java-api-rf-javax/activation/URLDataSource.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.