Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright (c) 2013, Francis Galiegue <>
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the Lesser GNU General Public License as
  * published by the Free Software Foundation, either version 3 of the
  * License, or (at your option) any later version.
  * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * Lesser GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <>.
package com.github.fge.jsonschema.load;
A downloader for the custom resource "scheme"

Here, resource is to be interpreted as a Java resource, exactly what you would obtain using java.lang.Class.getResourceAsStream(java.lang.String).

And in fact, this is what this downloader does: it takes whatever is in the provided URI's path (using and tries to make an input stream of it. The difference is that an will be thrown if the resource cannot be found (instead of returning null).

public final class ResourceURIDownloader
    implements URIDownloader
    private static final Class<ResourceURIDownloadermyself
        = ResourceURIDownloader.class;
    private static final URIDownloader INSTANCE = new ResourceURIDownloader();
    private ResourceURIDownloader()
    public static URIDownloader getInstance()
        return ;
    public InputStream fetch(final URI source)
        throws IOException
        final String resource = source.getPath();
        final InputStream in = .getResourceAsStream(resource);
        if (in == null)
            throw new IOException("resource " + resource + " not found");
        return in;
New to GrepCode? Check out our FAQ X