Package org.jppf.location
Class URLLocation
- All Implemented Interfaces:
Serializable,Location<URL>
- Direct Known Subclasses:
MavenLocation
Wrapper for manipulating data from a URL.
This implementation of the
Location interface allows writing to and reading from a URL.- Author:
- Laurent Cohen
- See Also:
-
Field Summary
Fields inherited from class org.jppf.location.AbstractLocation
eventsEnabled, listeners, path -
Constructor Summary
ConstructorsConstructorDescriptionURLLocation(String url) Initialize this location with the specified file path.URLLocation(URL url) Initialize this location with the specified file path. -
Method Summary
Modifier and TypeMethodDescriptionObtain an input stream to read from this location.Obtain an output stream to write to this location.longsize()This method attemps to get the size of the content pointed to by the URL.Methods inherited from class org.jppf.location.AbstractLocation
addLocationEventListener, copyTo, fireLocationEvent, getPath, removeLocationEventListener, toByteArray, toString
-
Constructor Details
-
URLLocation
Initialize this location with the specified file path.- Parameters:
url- aURL.
-
URLLocation
Initialize this location with the specified file path.- Parameters:
url- a URL in string format.- Throws:
MalformedURLException- if the url is malformed.
-
-
Method Details
-
getInputStream
Description copied from interface:LocationObtain an input stream to read from this location.- Returns:
- an
InputStreaminstance. - Throws:
Exception- if an I/O error occurs.
-
getOutputStream
Description copied from interface:LocationObtain an output stream to write to this location.- Returns:
- an
OutputStreaminstance. - Throws:
Exception- if an I/O error occurs.
-
size
public long size()This method attemps to get the size of the content pointed to by the URL. It may not always be possible, depending on the protocol and what's at the other end.- Returns:
- the content size if it is available, or -1 if it isn't.
-