Class URLLocation

All Implemented Interfaces:
Serializable, Location<URL>
Direct Known Subclasses:
MavenLocation

public class URLLocation extends AbstractLocation<URL>
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:
  • Constructor Details

    • URLLocation

      public URLLocation(URL url)
      Initialize this location with the specified file path.
      Parameters:
      url - a URL.
    • URLLocation

      public URLLocation(String url) throws MalformedURLException
      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

      public InputStream getInputStream() throws Exception
      Description copied from interface: Location
      Obtain an input stream to read from this location.
      Returns:
      an InputStream instance.
      Throws:
      Exception - if an I/O error occurs.
    • getOutputStream

      public OutputStream getOutputStream() throws Exception
      Description copied from interface: Location
      Obtain an output stream to write to this location.
      Returns:
      an OutputStream instance.
      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.