Package loci.common

Class URLHandle

java.lang.Object
loci.common.StreamHandle
loci.common.URLHandle
All Implemented Interfaces:
java.io.DataInput, java.io.DataOutput, IRandomAccess

public class URLHandle
extends StreamHandle
Provides random access to URLs using the IRandomAccess interface. Instances of URLHandle are read-only.
Author:
Melissa Linkert melissa at glencoesoftware.com
See Also:
IRandomAccess, StreamHandle, URLConnection
  • Constructor Details

    • URLHandle

      public URLHandle​(java.lang.String url) throws java.io.IOException
      Constructs a new URLHandle using the given URL.
      Parameters:
      url - the fully qualified URL path
      Throws:
      java.io.IOException - if the URL is invalid or unreadable
  • Method Details

    • seek

      public void seek​(long pos) throws java.io.IOException
      Description copied from interface: IRandomAccess
      Sets the stream pointer offset, measured from the beginning of this stream, at which the next read or write occurs.
      Specified by:
      seek in interface IRandomAccess
      Overrides:
      seek in class StreamHandle
      Parameters:
      pos - new byte offset (pointer) in the current stream. Unless otherwise noted, may be larger or smaller than the current pointer, but must be non-negative and less than the value of #length()
      Throws:
      java.io.IOException - if pos is invalid or the seek fails
      See Also:
      IRandomAccess.getFilePointer()
    • resetStream

      protected void resetStream() throws java.io.IOException
      Description copied from class: StreamHandle
      Close and reopen the stream; the stream pointer and mark should be reset to 0. This method is called if we need to seek backwards within the stream.
      Specified by:
      resetStream in class StreamHandle
      Throws:
      java.io.IOException - if the stream cannot be reset