URLDataSource (Java Platform SE 6) (original) (raw)
javax.activation
Class URLDataSource
java.lang.Object
javax.activation.URLDataSource
All Implemented Interfaces:
public class URLDataSource
extends Object
implements DataSource
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.
Since:
1.6
See Also:
Constructor Summary |
---|
URLDataSource(URL url) URLDataSource constructor. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, [wait](../../java/lang/Object.html#wait%28long, int%29) |
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'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.
Specified by:
[getContentType](../../javax/activation/DataSource.html#getContentType%28%29)
in interface [DataSource](../../javax/activation/DataSource.html "interface in javax.activation")
Returns:
the content type.
getName
public String getName()
Calls the getFile
method on the URL used to instantiate the object.
Specified by:
[getName](../../javax/activation/DataSource.html#getName%28%29)
in interface [DataSource](../../javax/activation/DataSource.html "interface in javax.activation")
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](../../javax/activation/DataSource.html#getInputStream%28%29)
in interface [DataSource](../../javax/activation/DataSource.html "interface in javax.activation")
Returns:
the InputStream.
Throws:
[IOException](../../java/io/IOException.html "class in java.io")
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](../../javax/activation/DataSource.html#getOutputStream%28%29)
in interface [DataSource](../../javax/activation/DataSource.html "interface in javax.activation")
Returns:
the OutputStream.
Throws:
[IOException](../../java/io/IOException.html "class in java.io")
getURL
public URL getURL()
Return the URL used to create this DataSource.
Returns:
The URL.
Submit a bug or feature
For further API reference and developer documentation, see Java SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
Scripting on this page tracks web page traffic, but does not change the content in any way.