/** * Constructs a new URLHandle using the given URL. */ public URLHandle(String url) throws IOException { if (!url.startsWith("http") && !url.startsWith("file:")) { url = "http://" + url; } this.url = url; resetStream(); }
/** Skip over the given number of bytes. */ private void skip(long bytes) throws IOException { long skipped = 0; while (skipped < bytes) { final long n = skipBytes(bytes - skipped); if (n == 0) break; skipped += n; } }
@Override public void seek(long pos) throws IOException { if (pos < fp && pos >= mark) { stream.reset(); fp = mark; skip(pos - fp); } else super.seek(pos); }
handle = new URLHandle(mapId);
@Override public void seek(long pos) throws IOException { if (pos < fp && pos >= mark) { stream.reset(); fp = mark; skip(pos - fp); } else super.seek(pos); }
handle = new URLHandle(mapId);
/** * Constructs a new URLHandle using the given URL. * * @param url the fully qualified URL path * @throws IOException if the URL is invalid or unreadable */ public URLHandle(String url) throws IOException { if (!url.startsWith("http") && !url.startsWith("file:")) { url = "http://" + url; } this.url = url; resetStream(); }
/** Skip over the given number of bytes. */ private void skip(long bytes) throws IOException { while (bytes >= Integer.MAX_VALUE) { bytes -= skipBytes(Integer.MAX_VALUE); } int skipped = skipBytes((int) bytes); while (skipped < bytes) { int n = skipBytes((int) (bytes - skipped)); if (n == 0) break; skipped += n; } }