/** * Determines whether the specified stream contains gzipped data, by * checking for the GZIP magic number, and returns a stream capable of * reading those data. * * @throws IOException */ public static InputStream detectCompression(InputStream stream) throws IOException { InputStream buffered; if (stream.markSupported()) buffered = stream; else buffered = new BufferedInputStream(stream); buffered.mark(2); int magic = readUShort(buffered); buffered.reset(); InputStream result; if (magic == GZIPInputStream.GZIP_MAGIC) result = new GZIPInputStream(buffered); else result = buffered; return result; }
public XMLResourceParser(InputStream in, String what, int depth, Set<URI> traversed, URI url) throws Exception { this.what = what; this.depth = depth; this.traversed = traversed; this.url = url; in = GZipUtils.detectCompression(in); addClose(in); this.reader = inputFactory.createXMLStreamReader(in); }
/** * Determines whether the specified stream contains gzipped data, by * checking for the GZIP magic number, and returns a stream capable of * reading those data. * * @throws IOException */ public static InputStream detectCompression(InputStream stream) throws IOException { InputStream buffered; if (stream.markSupported()) buffered = stream; else buffered = new BufferedInputStream(stream); buffered.mark(2); int magic = readUShort(buffered); buffered.reset(); InputStream result; if (magic == GZIPInputStream.GZIP_MAGIC) result = new GZIPInputStream(buffered); else result = buffered; return result; }
public XMLResourceParser(InputStream in, String what, int depth, Set<URI> traversed, URI url) throws Exception { this.what = what; this.depth = depth; this.traversed = traversed; this.url = url; in = GZipUtils.detectCompression(in); addClose(in); this.reader = inputFactory.createXMLStreamReader(in); }
/** * Determines whether the specified stream contains gzipped data, by * checking for the GZIP magic number, and returns a stream capable of * reading those data. * * @throws IOException */ public static InputStream detectCompression(InputStream stream) throws IOException { InputStream buffered; if (stream.markSupported()) buffered = stream; else buffered = new BufferedInputStream(stream); buffered.mark(2); int magic = readUShort(buffered); buffered.reset(); InputStream result; if (magic == GZIPInputStream.GZIP_MAGIC) result = new GZIPInputStream(buffered); else result = buffered; return result; }
@Override public void processReferral(URI parentUri, Referral referral, int maxDepth, int currentDepth) { try { URI indexLocation = new URI(referral.getUrl()); try { CachingUriResourceHandle indexHandle = new CachingUriResourceHandle(indexLocation, getCacheDirectory(), connector, null); indexHandle.setReporter(reporter); InputStream indexStream = GZipUtils.detectCompression(IO.stream(indexHandle.request())); readIndex(indexLocation.getPath(), indexLocation, indexStream, allContentProviders.values(), this, logService); } catch (Exception e) { warning("Unable to read referral index at URL '%s' from parent index '%s': %s", indexLocation, parentUri, e); } } catch (URISyntaxException e) { warning("Invalid referral URL '%s' from parent index '%s': %s", referral.getUrl(), parentUri, e); } }
/** * Determines whether the specified stream contains gzipped data, by * checking for the GZIP magic number, and returns a stream capable of * reading those data. * * @throws IOException */ public static InputStream detectCompression(InputStream stream) throws IOException { InputStream buffered; if (stream.markSupported()) buffered = stream; else buffered = new BufferedInputStream(stream); buffered.mark(2); int magic = readUShort(buffered); buffered.reset(); InputStream result; if (magic == GZIPInputStream.GZIP_MAGIC) result = new GZIPInputStream(buffered); else result = buffered; return result; }
@Override public void processReferral(URI parentUri, Referral referral, int maxDepth, int currentDepth) { try { URI indexLocation = new URI(referral.getUrl()); try { CachingUriResourceHandle indexHandle = new CachingUriResourceHandle(indexLocation, getCacheDirectory(), connector, null); indexHandle.setReporter(reporter); InputStream indexStream = GZipUtils.detectCompression(IO.stream(indexHandle.request())); readIndex(indexLocation.getPath(), indexLocation, indexStream, allContentProviders.values(), this, logService); } catch (Exception e) { warning("Unable to read referral index at URL '%s' from parent index '%s': %s", indexLocation, parentUri, e); } } catch (URISyntaxException e) { warning("Invalid referral URL '%s' from parent index '%s': %s", referral.getUrl(), parentUri, e); } }
InputStream indexStream = GZipUtils.detectCompression(IO.stream(indexFile)); readIndex(indexFile.getName(), indexLocation, indexStream, allContentProviders.values(), processor, logService);
InputStream indexStream = GZipUtils.detectCompression(IO.stream(indexFile)); readIndex(indexFile.getName(), indexLocation, indexStream, allContentProviders.values(), processor, logService);